diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/TimetablePagerAdapter.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/TimetablePagerAdapter.kt index 84d7a004..63ecdd6d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/TimetablePagerAdapter.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/v2/TimetablePagerAdapter.kt @@ -4,12 +4,17 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter import pl.szczodrzynski.edziennik.utils.models.Date +import pl.szczodrzynski.edziennik.utils.models.Week class TimetablePagerAdapter(val fragmentManager: FragmentManager, val items: List) : FragmentStatePagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { companion object { private const val TAG = "TimetablePagerAdapter" } + private val today by lazy { Date.getToday() } + private val weekStart by lazy { today.clone().stepForward(0, 0, -today.weekDay) } + private val weekEnd by lazy { weekStart.clone().stepForward(0, 0, 6) } + override fun getItem(position: Int): Fragment { return pl.szczodrzynski.edziennik.ui.modules.timetable.v2.day.TimetableDayFragment(items[position]) /*return TimetableDayFragment().apply { @@ -24,6 +29,11 @@ class TimetablePagerAdapter(val fragmentManager: FragmentManager, val items: Lis } override fun getPageTitle(position: Int): CharSequence? { - return items[position].formattedStringShort + val date = items[position] + val pageTitle = StringBuilder(Week.getFullDayName(date.weekDay)) + if (date > weekEnd || date < weekStart) { + pageTitle.append(", ").append(date.stringDm) + } + return pageTitle } } \ No newline at end of file