added mensa sunday workaround

* update mensa blocking un sundays between 1500 and 2359
* updated material-dialogs 2.2.0 -> 2.6.0
This commit is contained in:
Jannik 2019-03-27 13:29:36 +01:00
parent e08790aaa4
commit f97491addd
2 changed files with 17 additions and 5 deletions

View File

@ -13,9 +13,10 @@ android {
minSdkVersion 21
targetSdkVersion 28
versionCode 11
versionName "0.3.99"
versionName "0.4.0-rc1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "build_time", buildTime()
setProperty("archivesBaseName", "projectlaogai-$versionName")
}
buildTypes {
@ -44,8 +45,8 @@ dependencies {
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.afollestad:aesthetic:1.0.0-beta05'
implementation 'com.afollestad.material-dialogs:core:2.2.0'
implementation 'com.afollestad.material-dialogs:color:2.2.0'
implementation 'com.afollestad.material-dialogs:core:2.6.0'
implementation 'com.afollestad.material-dialogs:color:2.6.0'
testImplementation 'junit:junit:4.12'

View File

@ -171,12 +171,13 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
val currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK)
val cal = Calendar.getInstance()
// timetable sunday workaround
cal.time = Date(timetableCacheTime * 1000)
val timetableCacheDay = cal.get(Calendar.DAY_OF_WEEK)
// if the last update was on monday and now its a sunday, update before displaying the timetable
// TODO this sill backfire if someone has to update before the server finished updating the timetable at 0001/0101
if(currentDay == Calendar.MONDAY && timetableCacheDay == Calendar.SUNDAY) {
// update blocking if a) it`s monday and the last cache was not on a monday or b) the cache is older than 6 days
if((currentDay == Calendar.MONDAY && timetableCacheDay != Calendar.MONDAY) || (System.currentTimeMillis() / 1000) - timetableCacheTime > 518400) {
println("updating timetable after sunday!")
val jobA = tcor.getTimetable(cCourse.courseName, 0)
val jobB = tcor.getTimetable(cCourse.courseName, 1)
@ -185,6 +186,16 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
jobB.get()
}
// mensa sunday workaround
cal.time = Date(System.currentTimeMillis()) // reset to current time
// update blocking if it's sunday after 1500
// TODO and the last update was before 1500
if(currentDay == Calendar.SUNDAY && cal.get(Calendar.HOUR_OF_DAY) >= 15) {
val jobA = tcor.getMensa()
jobA.get()
}
// get the cached files
val cache = CacheController(this)
cache.readStartCache(cCourse.courseName)