sort of worked around the Sunday problem
This commit is contained in:
parent
953185425b
commit
a1410f7b80
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<string name="app_name" translatable="false">Project Laogai</string>
|
||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||
<string name="nav_header_title" translatable="false">hso App 0.3.95</string>
|
||||
<string name="nav_header_title" translatable="false">hso App 0.3.96</string>
|
||||
<string name="nav_header_subtitle" translatable="false">seil0@mosad.xyz</string>
|
||||
<string name="nav_header_desc" translatable="false">Project Laogai</string>
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
|||
<string name="accent_color_desc">The accent color, default is indigo.</string>
|
||||
<string name="show_buffet">always show buffet</string>
|
||||
<string name="select">select</string>
|
||||
<string name="version" translatable="false">version 0.3.95</string>
|
||||
<string name="version" translatable="false">version 0.3.96</string>
|
||||
<string name="about">about</string>
|
||||
<string name="about_txtView" translatable="false">hso App by @Seil0</string>
|
||||
<string name="about_text" translatable="false">"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 "</string>
|
||||
|
|
Loading…
Reference in New Issue