Compare commits

..

No commits in common. "6e9c63d3d47266b2c4e1a465f01af4fc139bc3e5" and "9c5274dc068c3f83810c56594aab7c5065f4bcf6" have entirely different histories.

2 changed files with 15 additions and 6 deletions

View File

@ -28,7 +28,10 @@ import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.google.gson.JsonParser
import com.google.gson.reflect.TypeToken
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.joinAll
import kotlinx.coroutines.launch
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cCourse
import org.mosad.seil0.projectlaogai.hsoparser.Course
import org.mosad.seil0.projectlaogai.hsoparser.MensaMenu
@ -108,7 +111,7 @@ class CacheController(cont: Context) {
// make sure the file exists
if (!file.exists())
runBlocking { TCoRAPIController.getCoursesList(context).join() }
GlobalScope.launch(Dispatchers.Default) { TCoRAPIController.getCoursesList(context).join() }
val fileReader = FileReader(file)
val bufferedReader = BufferedReader(fileReader)
@ -129,7 +132,7 @@ class CacheController(cont: Context) {
// make sure the file exists
if (!file.exists())
runBlocking { TCoRAPIController.getMensa(context).join() }
GlobalScope.launch(Dispatchers.Default) { TCoRAPIController.getMensa(context).join() }
val fileReader = FileReader(file)
val bufferedReader = BufferedReader(fileReader)
@ -147,8 +150,11 @@ class CacheController(cont: Context) {
val file = File(context.filesDir, "timetable-$courseName-$week.json")
// make sure the file exists
if (!file.exists())
runBlocking { TCoRAPIController.getTimetable(courseName, week, context).join() }
if (!file.exists()) {
GlobalScope.launch(Dispatchers.Default) {
TCoRAPIController.getTimetable(courseName, week, context).join()
}
}
val fileReader = FileReader(file)
val bufferedReader = BufferedReader(fileReader)

View File

@ -31,7 +31,10 @@ import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_home.*
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.mensaMenu
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timetables