mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-24 10:54:36 -06:00
[UI/Home] Show all next lessons before school day start.
This commit is contained in:
parent
9fde97bef0
commit
fedde9f739
@ -75,6 +75,7 @@ class HomeTimetableCard(
|
|||||||
private var counterJob: Job? = null
|
private var counterJob: Job? = null
|
||||||
private var counterStart: Time? = null
|
private var counterStart: Time? = null
|
||||||
private var counterEnd: Time? = null
|
private var counterEnd: Time? = null
|
||||||
|
private var showAllLessons: Boolean = false
|
||||||
private var subjectSpannable: CharSequence? = null
|
private var subjectSpannable: CharSequence? = null
|
||||||
|
|
||||||
private val ignoreCancelled = false
|
private val ignoreCancelled = false
|
||||||
@ -276,6 +277,8 @@ class HomeTimetableCard(
|
|||||||
counterJob = startCoroutineTimer(repeatMillis = 500) {
|
counterJob = startCoroutineTimer(repeatMillis = 500) {
|
||||||
count()
|
count()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showAllLessons = !isOngoing
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val isTomorrow = today.clone().stepForward(0, 0, 1) == timetableDate
|
val isTomorrow = today.clone().stepForward(0, 0, 1) == timetableDate
|
||||||
@ -312,12 +315,22 @@ class HomeTimetableCard(
|
|||||||
} ?: run {
|
} ?: run {
|
||||||
b.classroom.visibility = View.GONE
|
b.classroom.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showAllLessons = true
|
||||||
}
|
}
|
||||||
|
|
||||||
val text = mutableListOf<CharSequence>(
|
val text = mutableListOf<CharSequence>(
|
||||||
|
if (showAllLessons)
|
||||||
|
activity.getString(R.string.home_timetable_all_lessons)
|
||||||
|
else
|
||||||
activity.getString(R.string.home_timetable_later)
|
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) {
|
for (lesson in nextLessons) {
|
||||||
text += listOf(
|
text += listOf(
|
||||||
lesson.displayStartTime?.stringHM,
|
lesson.displayStartTime?.stringHM,
|
||||||
@ -348,6 +361,14 @@ class HomeTimetableCard(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val now = syncedNow
|
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) {
|
if (now > counterEnd) {
|
||||||
// the lesson is already over
|
// the lesson is already over
|
||||||
b.progress.visibility = View.GONE
|
b.progress.visibility = View.GONE
|
||||||
|
Loading…
Reference in New Issue
Block a user