[Timetable] Make going to the specified date on the notification click.

This commit is contained in:
Kacper Ziubryniewicz 2019-11-24 12:57:00 +01:00
parent 875efcff7e
commit 285b7e9b9e
2 changed files with 6 additions and 4 deletions

View File

@ -186,10 +186,10 @@ class DataNotifications(val data: Data) {
val luckyNumbers = app.db.luckyNumberDao().getNotNotifiedNow(profileId)
luckyNumbers?.removeAll { it.date < today }
luckyNumbers?.forEach { luckyNumber ->
val text = when {
luckyNumber.date.value == todayValue -> // LN for today
val text = when (luckyNumber.date.value) {
todayValue -> // LN for today
app.getString(if (profile.studentNumber != -1 && profile.studentNumber == luckyNumber.number) R.string.notification_lucky_number_yours_format else R.string.notification_lucky_number_format, luckyNumber.number)
luckyNumber.date.value == todayValue + 1 -> // LN for tomorrow
todayValue + 1 -> // LN for tomorrow
app.getString(if (profile.studentNumber != -1 && profile.studentNumber == luckyNumber.number) R.string.notification_lucky_number_yours_tomorrow_format else R.string.notification_lucky_number_tomorrow_format, luckyNumber.number)
else -> // LN for later
app.getString(if (profile.studentNumber != -1 && profile.studentNumber == luckyNumber.number) R.string.notification_lucky_number_yours_later_format else R.string.notification_lucky_number_later_format, luckyNumber.date.formattedString, luckyNumber.number)

View File

@ -155,8 +155,10 @@ class TimetableFragment : Fragment(), CoroutineScope {
}
})
val selectedDate = arguments?.getLong("timetableDate", -1)?.let { if (it == -1L) null else it.toInt() }
b.tabLayout.setUpWithViewPager(b.viewPager)
b.tabLayout.setCurrentItem(items.indexOfFirst { it.value == today }, false)
b.tabLayout.setCurrentItem(items.indexOfFirst { it.value == selectedDate ?: today }, false)
activity.navView.bottomSheet.prependItems(
BottomSheetPrimaryItem(true)