release 0.5.0 #35
|
@ -132,22 +132,13 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
|
||||
override fun onNavigationItemSelected(item: MenuItem): Boolean {
|
||||
// Handle navigation view item clicks here.
|
||||
when (item.itemId) {
|
||||
R.id.nav_home -> {
|
||||
activeFragment = HomeFragment()
|
||||
}
|
||||
R.id.nav_mensa -> {
|
||||
activeFragment = MensaFragment()
|
||||
}
|
||||
R.id.nav_timetable -> {
|
||||
activeFragment = TimeTableFragment()
|
||||
}
|
||||
R.id.nav_moodle -> {
|
||||
activeFragment = MoodleFragment()
|
||||
}
|
||||
R.id.nav_settings -> {
|
||||
activeFragment = SettingsFragment()
|
||||
}
|
||||
activeFragment = when(item.itemId) {
|
||||
R.id.nav_home -> HomeFragment()
|
||||
R.id.nav_mensa -> MensaFragment()
|
||||
R.id.nav_timetable -> TimeTableFragment()
|
||||
R.id.nav_moodle -> MoodleFragment()
|
||||
R.id.nav_settings -> SettingsFragment()
|
||||
else -> HomeFragment()
|
||||
}
|
||||
|
||||
val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
|
||||
|
@ -172,13 +163,12 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
val cal = Calendar.getInstance()
|
||||
|
||||
|
||||
// TODO this will backfire if someone has to update before the server finished updating the timetable at 0001/0101
|
||||
// timetable sunday workaround
|
||||
cal.time = Date(timetableCacheTime * 1000)
|
||||
val timetableCacheDay = cal.get(Calendar.DAY_OF_WEEK)
|
||||
|
||||
// TODO this will backfire if someone has to update before the server finished updating the timetable at 0001/0101
|
||||
// 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) {
|
||||
if((currentDay == Calendar.MONDAY && cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) || currentTime - timetableCacheTime > 518400) {
|
||||
println("updating timetable after sunday!")
|
||||
val jobA = TCoRAPIController.getTimetable(cCourse.courseName, 0, this)
|
||||
val jobB = TCoRAPIController.getTimetable(cCourse.courseName, 1, this)
|
||||
|
@ -188,28 +178,16 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
|||
}
|
||||
|
||||
|
||||
|
||||
// //mensa sunday workaround
|
||||
// cal.time = Date(System.currentTimeMillis()) // reset to current time
|
||||
//
|
||||
// // update blocking if it's sunday after 1500
|
||||
// if(currentDay == Calendar.SUNDAY && cal.get(Calendar.HOUR_OF_DAY) >= 15) {
|
||||
// TCoRAPIController.getMensa(this).get()
|
||||
// }
|
||||
|
||||
// TODO test!!
|
||||
// new sunday bug fix
|
||||
CacheController.readMensa(this)
|
||||
val mensaUpdateTime = Date(mensaMenu.meta.updateTime * 1000)
|
||||
cal.time = mensaUpdateTime
|
||||
cal.time = Date(mensaMenu.meta.updateTime * 1000)
|
||||
|
||||
// if it's monday and the last cache update was on sunday or is older than 24hr, update blocking
|
||||
if ((currentDay == Calendar.MONDAY && cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) || currentTime - mensaMenu.meta.updateTime > 86400) {
|
||||
println("update blocking")
|
||||
println("update mensa blocking")
|
||||
TCoRAPIController.getMensa(this).get()
|
||||
}
|
||||
|
||||
|
||||
// get the cached files
|
||||
val cache = CacheController(this)
|
||||
cache.readStartCache(cCourse.courseName)
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
|
||||
package org.mosad.seil0.projectlaogai.fragments
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ScrollView
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
|
@ -49,12 +51,14 @@ import org.mosad.seil0.projectlaogai.uicomponents.MealLinearLayout
|
|||
class MensaFragment : Fragment() {
|
||||
|
||||
private lateinit var btnCardValue: FloatingActionButton
|
||||
private lateinit var scrollViewMensa: ScrollView
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
||||
val view: View = inflater.inflate(R.layout.fragment_mensa, container, false)
|
||||
|
||||
btnCardValue = view.findViewById(R.id.btnCardValue)
|
||||
scrollViewMensa = view.findViewById(R.id.scrollView_Mensa)
|
||||
|
||||
// init actions
|
||||
initActions()
|
||||
|
@ -67,7 +71,6 @@ class MensaFragment : Fragment() {
|
|||
addWeek(mensaMenu.nextWeek, 0)
|
||||
|
||||
// TODO should we show a info if there is no more food this & next week?
|
||||
// TODO hide the floating button if we are not on the top end of the scroll pane
|
||||
|
||||
return view
|
||||
}
|
||||
|
@ -82,6 +85,19 @@ class MensaFragment : Fragment() {
|
|||
.show()
|
||||
}
|
||||
|
||||
// TODO only works with android m(23) or higher
|
||||
// hide the btnCardValue if the user is scrolling down
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
scrollViewMensa.setOnScrollChangeListener(object: View.OnScrollChangeListener {
|
||||
override fun onScrollChange(v: View?, scrollX: Int, scrollY: Int, oldScrollX: Int, oldScrollY: Int) {
|
||||
if (scrollY > oldScrollY) {
|
||||
btnCardValue.hide()
|
||||
} else {
|
||||
btnCardValue.show()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ import java.util.*
|
|||
*/
|
||||
class TimeTableFragment : Fragment() {
|
||||
|
||||
private val formatter = SimpleDateFormat("E dd.MM", Locale.getDefault()) // TODO change to android call when min api is 24
|
||||
private val formatter = SimpleDateFormat("E dd.MM", Locale.getDefault())
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent" android:id="@+id/scrollView_Mensa">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -22,6 +22,7 @@
|
|||
android:id="@+id/linLayout_Mensa"/>
|
||||
</ScrollView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:src="@drawable/ic_local_dining_black_24dp"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Loading…
Reference in New Issue