forked from github/szkolny
[Timetable] Fix showing question marks in lesson changes.
This commit is contained in:
parent
6d8960f089
commit
eaed4b76aa
@ -52,7 +52,7 @@ class TimetableDayFragment : Fragment(), CoroutineScope {
|
|||||||
private lateinit var date: Date
|
private lateinit var date: Date
|
||||||
private var startHour = DEFAULT_START_HOUR
|
private var startHour = DEFAULT_START_HOUR
|
||||||
private var endHour = DEFAULT_END_HOUR
|
private var endHour = DEFAULT_END_HOUR
|
||||||
private var firstEventMinute = 24*60
|
private var firstEventMinute = 24 * 60
|
||||||
|
|
||||||
// find SwipeRefreshLayout in the hierarchy
|
// find SwipeRefreshLayout in the hierarchy
|
||||||
private val refreshLayout by lazy { view?.findParentById(R.id.refreshLayout) }
|
private val refreshLayout by lazy { view?.findParentById(R.id.refreshLayout) }
|
||||||
@ -189,7 +189,7 @@ class TimetableDayFragment : Fragment(), CoroutineScope {
|
|||||||
val startTime = lesson.displayStartTime ?: continue
|
val startTime = lesson.displayStartTime ?: continue
|
||||||
val endTime = lesson.displayEndTime ?: continue
|
val endTime = lesson.displayEndTime ?: continue
|
||||||
|
|
||||||
firstEventMinute = min(firstEventMinute, startTime.hour*60 + startTime.minute)
|
firstEventMinute = min(firstEventMinute, startTime.hour * 60 + startTime.minute)
|
||||||
|
|
||||||
// Try to recycle an existing event view if there are enough left, otherwise inflate
|
// Try to recycle an existing event view if there are enough left, otherwise inflate
|
||||||
// a new one
|
// a new one
|
||||||
@ -265,26 +265,26 @@ class TimetableDayFragment : Fragment(), CoroutineScope {
|
|||||||
}
|
}
|
||||||
Lesson.TYPE_CHANGE -> {
|
Lesson.TYPE_CHANGE -> {
|
||||||
lb.annotationVisible = true
|
lb.annotationVisible = true
|
||||||
if (lesson.subjectId != lesson.oldSubjectId && lesson.teacherId != lesson.oldTeacherId) {
|
when {
|
||||||
lb.annotation.setText(
|
lesson.subjectId != lesson.oldSubjectId && lesson.teacherId != lesson.oldTeacherId
|
||||||
R.string.timetable_lesson_change_format,
|
&& lesson.oldSubjectName != null && lesson.oldTeacherName != null ->
|
||||||
"${lesson.oldSubjectName ?: "?"}, ${lesson.oldTeacherName ?: "?"}"
|
lb.annotation.setText(
|
||||||
)
|
R.string.timetable_lesson_change_format,
|
||||||
}
|
"${lesson.oldSubjectName ?: "?"}, ${lesson.oldTeacherName ?: "?"}"
|
||||||
else if (lesson.subjectId != lesson.oldSubjectId) {
|
)
|
||||||
lb.annotation.setText(
|
|
||||||
R.string.timetable_lesson_change_format,
|
lesson.subjectId != lesson.oldSubjectId && lesson.oldSubjectName != null ->
|
||||||
lesson.oldSubjectName ?: "?"
|
lb.annotation.setText(
|
||||||
)
|
R.string.timetable_lesson_change_format,
|
||||||
}
|
lesson.oldSubjectName ?: "?"
|
||||||
else if (lesson.teacherId != lesson.oldTeacherId) {
|
)
|
||||||
lb.annotation.setText(
|
|
||||||
R.string.timetable_lesson_change_format,
|
lesson.teacherId != lesson.oldTeacherId && lesson.oldTeacherName != null ->
|
||||||
lesson.oldTeacherName ?: "?"
|
lb.annotation.setText(
|
||||||
)
|
R.string.timetable_lesson_change_format,
|
||||||
}
|
lesson.oldTeacherName ?: "?"
|
||||||
else {
|
)
|
||||||
lb.annotation.setText(R.string.timetable_lesson_change)
|
else -> lb.annotation.setText(R.string.timetable_lesson_change)
|
||||||
}
|
}
|
||||||
|
|
||||||
lb.annotation.background.colorFilter = PorterDuffColorFilter(
|
lb.annotation.background.colorFilter = PorterDuffColorFilter(
|
||||||
@ -295,15 +295,19 @@ class TimetableDayFragment : Fragment(), CoroutineScope {
|
|||||||
Lesson.TYPE_SHIFTED_SOURCE -> {
|
Lesson.TYPE_SHIFTED_SOURCE -> {
|
||||||
lb.annotationVisible = true
|
lb.annotationVisible = true
|
||||||
when {
|
when {
|
||||||
lesson.date != lesson.oldDate -> lb.annotation.setText(
|
lesson.date != lesson.oldDate && lesson.date != null ->
|
||||||
R.string.timetable_lesson_shifted_other_day,
|
lb.annotation.setText(
|
||||||
lesson.date?.stringY_m_d ?: "?",
|
R.string.timetable_lesson_shifted_other_day,
|
||||||
lesson.startTime?.stringHM ?: "?"
|
lesson.date?.stringY_m_d ?: "?",
|
||||||
)
|
lesson.startTime?.stringHM ?: ""
|
||||||
lesson.startTime != lesson.oldStartTime -> lb.annotation.setText(
|
)
|
||||||
R.string.timetable_lesson_shifted_same_day,
|
|
||||||
lesson.startTime?.stringHM ?: "?"
|
lesson.startTime != lesson.oldStartTime && lesson.startTime != null ->
|
||||||
)
|
lb.annotation.setText(
|
||||||
|
R.string.timetable_lesson_shifted_same_day,
|
||||||
|
lesson.startTime?.stringHM ?: "?"
|
||||||
|
)
|
||||||
|
|
||||||
else -> lb.annotation.setText(R.string.timetable_lesson_shifted)
|
else -> lb.annotation.setText(R.string.timetable_lesson_shifted)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,15 +319,19 @@ class TimetableDayFragment : Fragment(), CoroutineScope {
|
|||||||
Lesson.TYPE_SHIFTED_TARGET -> {
|
Lesson.TYPE_SHIFTED_TARGET -> {
|
||||||
lb.annotationVisible = true
|
lb.annotationVisible = true
|
||||||
when {
|
when {
|
||||||
lesson.date != lesson.oldDate -> lb.annotation.setText(
|
lesson.date != lesson.oldDate && lesson.oldDate != null ->
|
||||||
R.string.timetable_lesson_shifted_from_other_day,
|
lb.annotation.setText(
|
||||||
lesson.oldDate?.stringY_m_d ?: "?",
|
R.string.timetable_lesson_shifted_from_other_day,
|
||||||
lesson.oldStartTime?.stringHM ?: "?"
|
lesson.oldDate?.stringY_m_d ?: "?",
|
||||||
)
|
lesson.oldStartTime?.stringHM ?: ""
|
||||||
lesson.startTime != lesson.oldStartTime -> lb.annotation.setText(
|
)
|
||||||
R.string.timetable_lesson_shifted_from_same_day,
|
|
||||||
lesson.oldStartTime?.stringHM ?: "?"
|
lesson.startTime != lesson.oldStartTime && lesson.oldStartTime != null ->
|
||||||
)
|
lb.annotation.setText(
|
||||||
|
R.string.timetable_lesson_shifted_from_same_day,
|
||||||
|
lesson.oldStartTime?.stringHM ?: "?"
|
||||||
|
)
|
||||||
|
|
||||||
else -> lb.annotation.setText(R.string.timetable_lesson_shifted_from)
|
else -> lb.annotation.setText(R.string.timetable_lesson_shifted_from)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +345,8 @@ class TimetableDayFragment : Fragment(), CoroutineScope {
|
|||||||
|
|
||||||
// The day view needs the event time ranges in the start minute/end minute format,
|
// The day view needs the event time ranges in the start minute/end minute format,
|
||||||
// so calculate those here
|
// so calculate those here
|
||||||
val startMinute = 60 * (lesson.displayStartTime?.hour ?: 0) + (lesson.displayStartTime?.minute ?: 0)
|
val startMinute = 60 * (lesson.displayStartTime?.hour
|
||||||
|
?: 0) + (lesson.displayStartTime?.minute ?: 0)
|
||||||
val endMinute = startMinute + 45
|
val endMinute = startMinute + 45
|
||||||
eventTimeRanges.add(DayView.EventTimeRange(startMinute, endMinute))
|
eventTimeRanges.add(DayView.EventTimeRange(startMinute, endMinute))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user