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 35338225..1b494ece 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 @@ -29,6 +29,7 @@ import pl.szczodrzynski.edziennik.* import pl.szczodrzynski.edziennik.data.api.edziennik.EdziennikTask import pl.szczodrzynski.edziennik.data.db.entity.Event.TYPE_HOMEWORK import pl.szczodrzynski.edziennik.data.db.entity.Lesson +import pl.szczodrzynski.edziennik.data.db.entity.Lesson.Companion.TYPE_NO_LESSONS import pl.szczodrzynski.edziennik.ui.widgets.LessonDialogActivity import pl.szczodrzynski.edziennik.ui.widgets.WidgetConfig import pl.szczodrzynski.edziennik.utils.models.Date @@ -77,7 +78,7 @@ class WidgetTimetableProvider : AppWidgetProvider() { super.onReceive(context, intent) } - private val ignoreCancelled = true + private val ignoreCancelled = false override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) { val thisWidget = ComponentName(context, WidgetTimetableProvider::class.java) @@ -280,6 +281,8 @@ class WidgetTimetableProvider : AppWidgetProvider() { val events = app.db.eventDao().getAllByDateNow(profile.id, timetableDate)?.filterNotNull() ?: emptyList() lessons.forEachIndexed { pos, lesson -> + if (lesson.type == TYPE_NO_LESSONS) + return@forEachIndexed val model = ItemWidgetTimetableModel() model.bigStyle = widgetConfig.bigStyle @@ -289,8 +292,8 @@ class WidgetTimetableProvider : AppWidgetProvider() { model.lessonId = lesson.id model.lessonDate = timetableDate - model.startTime = lesson.displayStartTime - model.endTime = lesson.displayEndTime + model.startTime = lesson.displayStartTime ?: return@forEachIndexed + model.endTime = lesson.displayEndTime ?: return@forEachIndexed // check if the lesson has already passed or it's currently in progress if (lesson.displayDate == today) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java index 2e382205..d45f1f35 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/models/ItemWidgetTimetableModel.java @@ -1,5 +1,7 @@ package pl.szczodrzynski.edziennik.utils.models; +import androidx.annotation.NonNull; + import java.util.ArrayList; import java.util.List; @@ -11,7 +13,9 @@ public class ItemWidgetTimetableModel { public int profileId; public long lessonId; public Date lessonDate; + @NonNull public Time startTime; + @NonNull public Time endTime; public boolean lessonPassed; public boolean lessonCurrent;