forked from github/wulkanowy-mirror
Add debug statements to get/update methods in grade details adapter (#827)
This commit is contained in:
parent
9c01316178
commit
f737018548
@ -133,6 +133,7 @@ class GradePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun loadChild(index: Int, forceRefresh: Boolean = false) {
|
||||
Timber.d("Load grade tab child. Selected semester: $selectedIndex, semesters: ${semesters.joinToString { it.semesterName.toString() }}")
|
||||
semesters.first { it.semesterName == selectedIndex }.semesterId.also {
|
||||
if (forceRefresh || loadedSemesterId[index] != it) {
|
||||
Timber.i("Load grade child view index: $index")
|
||||
|
@ -14,6 +14,7 @@ import io.github.wulkanowy.databinding.ItemGradeDetailsBinding
|
||||
import io.github.wulkanowy.ui.base.BaseExpandableAdapter
|
||||
import io.github.wulkanowy.utils.getBackgroundColor
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class GradeDetailsAdapter @Inject constructor() : BaseExpandableAdapter<RecyclerView.ViewHolder>() {
|
||||
@ -38,12 +39,26 @@ class GradeDetailsAdapter @Inject constructor() : BaseExpandableAdapter<Recycler
|
||||
}
|
||||
|
||||
fun updateDetailsItem(position: Int, grade: Grade) {
|
||||
if (items.getOrNull(position)?.viewType != ViewType.ITEM) {
|
||||
Timber.e("Trying to update item $position on list ${items.size} size, expanded position: $expandedPosition")
|
||||
return
|
||||
}
|
||||
items[position] = GradeDetailsItem(grade, ViewType.ITEM)
|
||||
notifyItemChanged(position)
|
||||
}
|
||||
|
||||
fun getHeaderItem(subject: String): GradeDetailsItem {
|
||||
return headers.single { (it.value as GradeDetailsHeader).subject == subject }
|
||||
if (headers.any { it.value !is GradeDetailsHeader }) {
|
||||
Timber.e("Headers contains no-header items! $headers")
|
||||
}
|
||||
|
||||
val candidates = headers.filter { (it.value as GradeDetailsHeader).subject == subject }
|
||||
|
||||
if (candidates.size > 1) {
|
||||
Timber.e("Header with subject $subject found ${candidates.size} times! Items: $candidates, expanded: $expandedPosition")
|
||||
}
|
||||
|
||||
return candidates.first()
|
||||
}
|
||||
|
||||
fun updateHeaderItem(item: GradeDetailsItem) {
|
||||
@ -92,7 +107,7 @@ class GradeDetailsAdapter @Inject constructor() : BaseExpandableAdapter<Recycler
|
||||
is ItemViewHolder -> bindItemViewHolder(
|
||||
binding = holder.binding,
|
||||
grade = items[position].value as Grade,
|
||||
position = position
|
||||
position = holder.adapterPosition
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onGradeItemSelected(grade: Grade, position: Int) {
|
||||
Timber.i("Select grade item ${grade.id}")
|
||||
Timber.i("Select grade item ${grade.id}, position: $position")
|
||||
view?.apply {
|
||||
showGradeDialog(grade, preferencesRepository.gradeColorTheme)
|
||||
if (!grade.isRead) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user