diff --git a/app/build.gradle b/app/build.gradle
index a15baf9..0fce1af 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -13,7 +13,7 @@ android {
minSdkVersion 21
targetSdkVersion 28
versionCode 11
- versionName "0.3.95"
+ versionName "0.3.96"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
diff --git a/app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt b/app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
index f675edf..3e65409 100644
--- a/app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
+++ b/app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
@@ -45,6 +45,8 @@ import org.mosad.seil0.projectlaogai.controller.CacheController
import org.mosad.seil0.projectlaogai.controller.PreferencesController
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
import org.mosad.seil0.projectlaogai.fragments.*
+import java.sql.Date
+import java.util.*
import kotlin.system.measureTimeMillis
class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
@@ -164,15 +166,30 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
PreferencesController.load(this) // this must be finished before doing anything else
val startupTime = measureTimeMillis {
+ val tcor = TCoRAPIController(this)
+ val currentTime = System.currentTimeMillis() / 1000
+ val currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK)
+ val cal = Calendar.getInstance()
+
+ cal.time = Date(timetableCacheTime * 1000)
+ val timetableCacheDay = cal.get(Calendar.DAY_OF_WEEK)
+
+ // if the last update was on moday and now its a sunday, update before displaying the timetable
+ // TODO this sill backfire if someone has to update before the server finished updateing the timetable at 0001/0101
+ if(currentDay == Calendar.MONDAY && timetableCacheDay == Calendar.SUNDAY) {
+ println("updating timetable after sunday!")
+ val jobA = tcor.getTimetable(cCourse.courseName, 0)
+ val jobB = tcor.getTimetable(cCourse.courseName, 1)
+
+ jobA.get()
+ jobB.get()
+ }
// get the cached files
val cache = CacheController(this)
cache.readStartCache(cCourse.courseName)
// check if an update is necessary
- val tcor = TCoRAPIController(this)
- val currentTime = System.currentTimeMillis() / 1000
-
if(currentTime - coursesCacheTime > 86400)
tcor.getCoursesList()
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0267aef..ebc8935 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -2,7 +2,7 @@
Project Laogai
Open navigation drawer
Close navigation drawer
- hso App 0.3.95
+ hso App 0.3.96
seil0@mosad.xyz
Project Laogai
@@ -40,7 +40,7 @@
The accent color, default is indigo.
always show buffet
select
- version 0.3.95
+ version 0.3.96
about
hso App by @Seil0
"This software is made by @Seil0 and is published under the terms and conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018-2019 seil0@mosad.xyz "