mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 19:02:45 +01:00
Fix crash in timetable time left (#826)
This commit is contained in:
parent
f737018548
commit
cec1068f2e
@ -132,41 +132,46 @@ class TimetableAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerView
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTimeLeft(binding: ItemTimetableBinding, lesson: Timetable, position: Int) {
|
private fun updateTimeLeft(binding: ItemTimetableBinding, lesson: Timetable, position: Int) {
|
||||||
|
val isShowTimeUntil = lesson.isShowTimeUntil(getPreviousLesson(position))
|
||||||
|
val until = lesson.until
|
||||||
|
val left = lesson.left
|
||||||
|
val isJustFinished = lesson.isJustFinished
|
||||||
|
|
||||||
with(binding) {
|
with(binding) {
|
||||||
when {
|
when {
|
||||||
// before lesson
|
// before lesson
|
||||||
lesson.isShowTimeUntil(getPreviousLesson(position)) -> {
|
isShowTimeUntil -> {
|
||||||
Timber.d("Show time until lesson: $position")
|
Timber.d("Show time until lesson: $position")
|
||||||
timetableItemTimeLeft.visibility = GONE
|
timetableItemTimeLeft.visibility = GONE
|
||||||
with(timetableItemTimeUntil) {
|
with(timetableItemTimeUntil) {
|
||||||
visibility = VISIBLE
|
visibility = VISIBLE
|
||||||
text = context.getString(R.string.timetable_time_until,
|
text = context.getString(R.string.timetable_time_until,
|
||||||
if (lesson.until.seconds <= 60) {
|
if (until.seconds <= 60) {
|
||||||
context.getString(R.string.timetable_seconds, lesson.until.seconds.toString(10))
|
context.getString(R.string.timetable_seconds, until.seconds.toString(10))
|
||||||
} else {
|
} 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
|
// after lesson start
|
||||||
lesson.left != null -> {
|
left != null -> {
|
||||||
Timber.d("Show time left lesson: $position")
|
Timber.d("Show time left lesson: $position")
|
||||||
timetableItemTimeUntil.visibility = GONE
|
timetableItemTimeUntil.visibility = GONE
|
||||||
with(timetableItemTimeLeft) {
|
with(timetableItemTimeLeft) {
|
||||||
visibility = VISIBLE
|
visibility = VISIBLE
|
||||||
text = context.getString(
|
text = context.getString(
|
||||||
R.string.timetable_time_left,
|
R.string.timetable_time_left,
|
||||||
if (lesson.left!!.seconds < 60) {
|
if (left.seconds < 60) {
|
||||||
context.getString(R.string.timetable_seconds, lesson.left?.seconds?.toString(10))
|
context.getString(R.string.timetable_seconds, left.seconds.toString(10))
|
||||||
} else {
|
} 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
|
// right after lesson finish
|
||||||
lesson.isJustFinished -> {
|
isJustFinished -> {
|
||||||
Timber.d("Show just finished lesson: $position")
|
Timber.d("Show just finished lesson: $position")
|
||||||
timetableItemTimeUntil.visibility = GONE
|
timetableItemTimeUntil.visibility = GONE
|
||||||
timetableItemTimeLeft.visibility = VISIBLE
|
timetableItemTimeLeft.visibility = VISIBLE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user