From cec1068f2e3cc0279537edbcad5f957cc35f4538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sun, 24 May 2020 19:34:10 +0200 Subject: [PATCH] Fix crash in timetable time left (#826) --- .../ui/modules/timetable/TimetableAdapter.kt | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableAdapter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableAdapter.kt index 5354442aa..85ded2025 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableAdapter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableAdapter.kt @@ -132,41 +132,46 @@ class TimetableAdapter @Inject constructor() : RecyclerView.Adapter { + isShowTimeUntil -> { Timber.d("Show time until lesson: $position") timetableItemTimeLeft.visibility = GONE with(timetableItemTimeUntil) { visibility = VISIBLE text = context.getString(R.string.timetable_time_until, - if (lesson.until.seconds <= 60) { - context.getString(R.string.timetable_seconds, lesson.until.seconds.toString(10)) + if (until.seconds <= 60) { + context.getString(R.string.timetable_seconds, until.seconds.toString(10)) } else { - context.getString(R.string.timetable_minutes, lesson.until.toMinutes().toString(10)) + context.getString(R.string.timetable_minutes, until.toMinutes().toString(10)) } ) } } // after lesson start - lesson.left != null -> { + left != null -> { Timber.d("Show time left lesson: $position") timetableItemTimeUntil.visibility = GONE with(timetableItemTimeLeft) { visibility = VISIBLE text = context.getString( R.string.timetable_time_left, - if (lesson.left!!.seconds < 60) { - context.getString(R.string.timetable_seconds, lesson.left?.seconds?.toString(10)) + if (left.seconds < 60) { + context.getString(R.string.timetable_seconds, left.seconds.toString(10)) } else { - context.getString(R.string.timetable_minutes, lesson.left?.toMinutes()?.toString(10)) + context.getString(R.string.timetable_minutes, left.toMinutes().toString(10)) } ) } } // right after lesson finish - lesson.isJustFinished -> { + isJustFinished -> { Timber.d("Show just finished lesson: $position") timetableItemTimeUntil.visibility = GONE timetableItemTimeLeft.visibility = VISIBLE