Browse Source

sort of worked around the Sunday problem

pull/20/head
Jannik 3 years ago
parent
commit
a1410f7b80
  1. 2
      app/build.gradle
  2. 23
      app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt
  3. 4
      app/src/main/res/values/strings.xml

2
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 {

23
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()

4
app/src/main/res/values/strings.xml

@ -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…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close