From df1a241b2b1acfcbe79dbb0a0f977686d015bec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Tue, 10 Mar 2020 22:01:30 +0100 Subject: [PATCH] [Timetable] Fix showing "no timetable" when all nearest lessons are cancelled. Fix a crash in timetable fragment. --- .../edziennik/ui/modules/home/cards/HomeTimetableCard.kt | 4 ++-- .../edziennik/ui/modules/timetable/TimetableFragment.kt | 2 ++ .../edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt index f3d5a88b..a675b418 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeTimetableCard.kt @@ -166,8 +166,8 @@ class HomeTimetableCard( && !(it.isCancelled && ignoreCancelled) } - if (lessons.isEmpty() && timetableDate.weekDay <= 5) - break + //if (lessons.isEmpty() && timetableDate.weekDay <= 5) + // break checkedDays++ } diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/TimetableFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/TimetableFragment.kt index fb23116c..158f3549 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/TimetableFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/timetable/TimetableFragment.kt @@ -124,6 +124,8 @@ class TimetableFragment : Fragment(), CoroutineScope { endHour = lessonRanges.map { it.endTime.hour }.max()?.plus(1) ?: DEFAULT_END_HOUR } deferred.await() + if (!isAdded) + return@launch val pagerAdapter = TimetablePagerAdapter( fragmentManager ?: return@launch, diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt index c086cf53..85073b58 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/widgets/timetable/WidgetTimetableProvider.kt @@ -229,8 +229,8 @@ class WidgetTimetableProvider : AppWidgetProvider() { && !(it.isCancelled && ignoreCancelled) } - if (lessons.isEmpty() && timetableDate.weekDay <= 5) - break + //if (lessons.isEmpty() && timetableDate.weekDay <= 5) + // break checkedDays++ }