Skip to content

Commit

Permalink
[UI/Home] Show all next lessons before school day start.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Oct 26, 2022
1 parent 9fde97b commit fedde9f
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class HomeTimetableCard(
private var counterJob: Job? = null
private var counterStart: Time? = null
private var counterEnd: Time? = null
private var showAllLessons: Boolean = false
private var subjectSpannable: CharSequence? = null

private val ignoreCancelled = false
Expand Down Expand Up @@ -276,6 +277,8 @@ class HomeTimetableCard(
counterJob = startCoroutineTimer(repeatMillis = 500) {
count()
}

showAllLessons = !isOngoing
}
else {
val isTomorrow = today.clone().stepForward(0, 0, 1) == timetableDate
Expand Down Expand Up @@ -312,12 +315,22 @@ class HomeTimetableCard(
} ?: run {
b.classroom.visibility = View.GONE
}

showAllLessons = true
}

val text = mutableListOf<CharSequence>(
if (showAllLessons)
activity.getString(R.string.home_timetable_all_lessons)
else
activity.getString(R.string.home_timetable_later)
)
val nextLessons = lessons.drop(skipFirst + 1)

val nextLessons = if (showAllLessons)
lessons.drop(skipFirst)
else
lessons.drop(skipFirst + 1)

for (lesson in nextLessons) {
text += listOf(
lesson.displayStartTime?.stringHM,
Expand Down Expand Up @@ -348,6 +361,14 @@ class HomeTimetableCard(
}

val now = syncedNow
if (now >= counterStart && showAllLessons) {
// update "next lessons" view to remove current lesson
this.counterJob?.cancel()
this.counterStart = null
this.counterEnd = null
update()
return
}
if (now > counterEnd) {
// the lesson is already over
b.progress.visibility = View.GONE
Expand Down

0 comments on commit fedde9f

Please sign in to comment.