use cache if qispos is not available
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
d6eb1ff1e5
commit
cb1f43ec66
|
@ -62,9 +62,18 @@ class GradesFragment : Fragment() {
|
|||
|
||||
parser = QISPOSParser(context!!)// init the parser
|
||||
|
||||
// TODO if loading from cache, don't check Qispos state
|
||||
if (checkCredentials() && checkQisposStatus()) {
|
||||
if (checkCredentials()) {
|
||||
GlobalScope.launch(Dispatchers.Default) {
|
||||
// if the cache is older than 24hr, update blocking
|
||||
val currentTime = System.currentTimeMillis() / 1000
|
||||
if ((currentTime - Preferences.gradesCacheTime) > 86400 && checkQisposStatus()) {
|
||||
withContext(Dispatchers.Main) {
|
||||
refreshLayout_Grades.isRefreshing = true
|
||||
}
|
||||
|
||||
CacheController.updateGrades(context!!).join()
|
||||
}
|
||||
|
||||
addGrades()
|
||||
}
|
||||
}
|
||||
|
@ -145,17 +154,6 @@ class GradesFragment : Fragment() {
|
|||
*/
|
||||
private fun addGrades() = GlobalScope.launch(Dispatchers.Default) {
|
||||
val addGradesTime = measureTimeMillis {
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
refreshLayout_Grades.isRefreshing = true
|
||||
}
|
||||
|
||||
// if the cache is older than 24hr, update blocking
|
||||
val currentTime = System.currentTimeMillis() / 1000
|
||||
if ((currentTime - Preferences.gradesCacheTime) > 86400) {
|
||||
CacheController.updateGrades(context!!).join()
|
||||
}
|
||||
|
||||
val grades = CacheController(context!!).readGrades()
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
|
|
Loading…
Reference in New Issue