mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-18 21:26:48 -06:00
Hide lesson number when is eduOne (#2498)
This commit is contained in:
parent
c9a42a6cf6
commit
5a77d1e940
@ -27,7 +27,7 @@ class TimetableAdapter @Inject constructor() :
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
|
||||
return when (TimetableItemType.values()[viewType]) {
|
||||
return when (TimetableItemType.entries[viewType]) {
|
||||
TimetableItemType.SMALL -> SmallViewHolder(
|
||||
ItemTimetableSmallBinding.inflate(inflater, parent, false)
|
||||
)
|
||||
@ -79,6 +79,7 @@ class TimetableAdapter @Inject constructor() :
|
||||
|
||||
with(binding) {
|
||||
timetableSmallItemNumber.text = lesson.number.toString()
|
||||
timetableSmallItemNumber.isVisible = item.isLessonNumberVisible
|
||||
timetableSmallItemSubject.text = lesson.subject
|
||||
timetableSmallItemTimeStart.text = lesson.start.toFormattedString("HH:mm")
|
||||
timetableSmallItemRoom.text = lesson.room
|
||||
@ -97,6 +98,7 @@ class TimetableAdapter @Inject constructor() :
|
||||
|
||||
with(binding) {
|
||||
timetableItemNumber.text = lesson.number.toString()
|
||||
timetableItemNumber.isVisible = item.isLessonNumberVisible
|
||||
timetableItemSubject.text = lesson.subject
|
||||
timetableItemGroup.text = lesson.group
|
||||
timetableItemRoom.text = lesson.room
|
||||
|
@ -7,12 +7,14 @@ sealed class TimetableItem(val type: TimetableItemType) {
|
||||
|
||||
data class Small(
|
||||
val lesson: Timetable,
|
||||
val isLessonNumberVisible: Boolean,
|
||||
val onClick: (Timetable) -> Unit,
|
||||
) : TimetableItem(TimetableItemType.SMALL)
|
||||
|
||||
data class Normal(
|
||||
val lesson: Timetable,
|
||||
val showGroupsInPlan: Boolean,
|
||||
val isLessonNumberVisible: Boolean,
|
||||
val timeLeft: TimeLeft?,
|
||||
val onClick: (Timetable) -> Unit,
|
||||
) : TimetableItem(TimetableItemType.NORMAL)
|
||||
|
@ -57,6 +57,7 @@ class TimetablePresenter @Inject constructor(
|
||||
|
||||
private var initialDate: LocalDate? = null
|
||||
private var isWeekendHasLessons: Boolean = false
|
||||
private var isEduOne: Boolean = false
|
||||
|
||||
var currentDate: LocalDate? = null
|
||||
private set
|
||||
@ -149,6 +150,7 @@ class TimetablePresenter @Inject constructor(
|
||||
val student = studentRepository.getCurrentStudent()
|
||||
val semester = semesterRepository.getCurrentSemester(student)
|
||||
|
||||
isEduOne = student.isEduOne
|
||||
checkInitialAndCurrentDate(semester)
|
||||
timetableRepository.getTimetable(
|
||||
student = student,
|
||||
@ -234,9 +236,8 @@ class TimetablePresenter @Inject constructor(
|
||||
if (prefRepository.showWholeClassPlan == TimetableMode.ONLY_CURRENT_GROUP) {
|
||||
it.isStudentPlan
|
||||
} else true
|
||||
}.sortedWith(
|
||||
compareBy({ item -> item.number }, { item -> !item.isStudentPlan })
|
||||
)
|
||||
}
|
||||
.sortedWith(compareBy({ item -> item.start }, { item -> !item.isStudentPlan }))
|
||||
|
||||
var prevNum = when (prefRepository.showTimetableGaps) {
|
||||
BETWEEN_AND_BEFORE_LESSONS -> 0
|
||||
@ -257,13 +258,15 @@ class TimetablePresenter @Inject constructor(
|
||||
lesson = it,
|
||||
showGroupsInPlan = prefRepository.showGroupsInPlan,
|
||||
timeLeft = filteredItems.getTimeLeftForLesson(it, i),
|
||||
onClick = ::onTimetableItemSelected
|
||||
onClick = ::onTimetableItemSelected,
|
||||
isLessonNumberVisible = !isEduOne
|
||||
)
|
||||
add(normalLesson)
|
||||
} else {
|
||||
val smallLesson = TimetableItem.Small(
|
||||
lesson = it,
|
||||
onClick = ::onTimetableItemSelected
|
||||
onClick = ::onTimetableItemSelected,
|
||||
isLessonNumberVisible = !isEduOne
|
||||
)
|
||||
add(smallLesson)
|
||||
}
|
||||
|
@ -46,11 +46,8 @@ class TimetableWidgetFactory(
|
||||
) : RemoteViewsService.RemoteViewsFactory {
|
||||
|
||||
private var items = emptyList<TimetableWidgetItem>()
|
||||
|
||||
private var timetableCanceledColor: Int? = null
|
||||
|
||||
private var textColor: Int? = null
|
||||
|
||||
private var timetableChangeColor: Int? = null
|
||||
|
||||
override fun getLoadingView() = null
|
||||
@ -81,7 +78,7 @@ class TimetableWidgetFactory(
|
||||
val lessons = getLessons(student, semester, date)
|
||||
val lastSync = timetableRepository.getLastRefreshTimestamp(semester, date, date)
|
||||
|
||||
createItems(lessons, lastSync)
|
||||
createItems(lessons, lastSync, !student.isEduOne)
|
||||
}
|
||||
.onFailure {
|
||||
items = listOf(TimetableWidgetItem.Error(it))
|
||||
@ -106,12 +103,13 @@ class TimetableWidgetFactory(
|
||||
): List<Timetable> {
|
||||
val timetable = timetableRepository.getTimetable(student, semester, date, date, false)
|
||||
val lessons = timetable.toFirstResult().dataOrThrow.lessons
|
||||
return lessons.sortedBy { it.number }
|
||||
return lessons.sortedBy { it.start }
|
||||
}
|
||||
|
||||
private fun createItems(
|
||||
lessons: List<Timetable>,
|
||||
lastSync: Instant?,
|
||||
isEduOne: Boolean
|
||||
): List<TimetableWidgetItem> {
|
||||
var prevNum = when (prefRepository.showTimetableGaps) {
|
||||
BETWEEN_AND_BEFORE_LESSONS -> 0
|
||||
@ -127,7 +125,7 @@ class TimetableWidgetFactory(
|
||||
)
|
||||
add(emptyItem)
|
||||
}
|
||||
add(TimetableWidgetItem.Normal(it))
|
||||
add(TimetableWidgetItem.Normal(it, isEduOne))
|
||||
prevNum = it.number
|
||||
}
|
||||
add(TimetableWidgetItem.Synchronized(lastSync ?: Instant.MIN))
|
||||
@ -155,9 +153,11 @@ class TimetableWidgetFactory(
|
||||
|
||||
val lessonStartTime = lesson.start.toFormattedString(TIME_FORMAT_STYLE)
|
||||
val lessonEndTime = lesson.end.toFormattedString(TIME_FORMAT_STYLE)
|
||||
val lessonNumberVisibility = if (item.isLessonNumberVisible) VISIBLE else GONE
|
||||
|
||||
val remoteViews = RemoteViews(context.packageName, R.layout.item_widget_timetable).apply {
|
||||
setTextViewText(R.id.timetableWidgetItemNumber, lesson.number.toString())
|
||||
setViewVisibility(R.id.timetableWidgetItemNumber, lessonNumberVisibility)
|
||||
setTextViewText(R.id.timetableWidgetItemTimeStart, lessonStartTime)
|
||||
setTextViewText(R.id.timetableWidgetItemTimeFinish, lessonEndTime)
|
||||
setTextViewText(R.id.timetableWidgetItemSubject, lesson.subject)
|
||||
|
@ -7,6 +7,7 @@ sealed class TimetableWidgetItem(val type: TimetableWidgetItemType) {
|
||||
|
||||
data class Normal(
|
||||
val lesson: Timetable,
|
||||
val isLessonNumberVisible: Boolean,
|
||||
) : TimetableWidgetItem(TimetableWidgetItemType.NORMAL)
|
||||
|
||||
data class Empty(
|
||||
|
Loading…
x
Reference in New Issue
Block a user