Browse Source

added mensa sunday workaround

* update mensa blocking un sundays between 1500 and 2359
* updated material-dialogs 2.2.0 -> 2.6.0
pull/20/head
Jannik 3 years ago
parent
commit
f97491addd
  1. 7
      app/build.gradle
  2. 15
      app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt

7
app/build.gradle

@ -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'

15
app/src/main/java/org/mosad/seil0/projectlaogai/MainActivity.kt

@ -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)

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