[Timetable] Change date receiver argument to timetableDate.

This commit is contained in:
Kacper Ziubryniewicz 2019-11-24 13:20:22 +01:00
parent 285b7e9b9e
commit d274a2fed1
3 changed files with 6 additions and 6 deletions

View File

@ -55,7 +55,7 @@ class DataNotifications(val data: Data) {
profileName = profileName, profileName = profileName,
viewId = DRAWER_ITEM_TIMETABLE, viewId = DRAWER_ITEM_TIMETABLE,
addedDate = lesson.addedDate addedDate = lesson.addedDate
).addExtra("timetableDate", lesson.displayDate?.value?.toLong()) ).addExtra("timetableDate", lesson.displayDate?.stringY_m_d ?: "")
} }
for (event in app.db.eventDao().getNotNotifiedNow(profileId)) { for (event in app.db.eventDao().getNotNotifiedNow(profileId)) {

View File

@ -120,7 +120,7 @@ class LessonDetailsDialog(
dialog.dismiss() dialog.dismiss()
val dateStr = otherLessonDate?.stringY_m_d ?: return@setOnClickListener val dateStr = otherLessonDate?.stringY_m_d ?: return@setOnClickListener
val intent = Intent(TimetableFragment.ACTION_SCROLL_TO_DATE).apply { val intent = Intent(TimetableFragment.ACTION_SCROLL_TO_DATE).apply {
putExtra("date", dateStr) putExtra("timetableDate", dateStr)
} }
activity.sendBroadcast(intent) activity.sendBroadcast(intent)
} }
@ -157,4 +157,4 @@ class LessonDetailsDialog(
b.teamName = lesson.teamName b.teamName = lesson.teamName
} }
} }
} }

View File

@ -67,7 +67,7 @@ class TimetableFragment : Fragment(), CoroutineScope {
override fun onReceive(context: Context, i: Intent) { override fun onReceive(context: Context, i: Intent) {
if (!isAdded) if (!isAdded)
return return
val dateStr = i.extras?.getString("date", null) ?: return val dateStr = i.extras?.getString("timetableDate", null) ?: return
val date = Date.fromY_m_d(dateStr) val date = Date.fromY_m_d(dateStr)
b.viewPager.setCurrentItem(items.indexOf(date), true) b.viewPager.setCurrentItem(items.indexOf(date), true)
} }
@ -155,10 +155,10 @@ class TimetableFragment : Fragment(), CoroutineScope {
} }
}) })
val selectedDate = arguments?.getLong("timetableDate", -1)?.let { if (it == -1L) null else it.toInt() } val selectedDate = arguments?.getString("timetableDate", "")?.let { if (it.isBlank()) null else Date.fromY_m_d(it) }
b.tabLayout.setUpWithViewPager(b.viewPager) b.tabLayout.setUpWithViewPager(b.viewPager)
b.tabLayout.setCurrentItem(items.indexOfFirst { it.value == selectedDate ?: today }, false) b.tabLayout.setCurrentItem(items.indexOfFirst { it.value == selectedDate?.value ?: today }, false)
activity.navView.bottomSheet.prependItems( activity.navView.bottomSheet.prependItems(
BottomSheetPrimaryItem(true) BottomSheetPrimaryItem(true)