forked from github/wulkanowy-mirror
Fix grade header item object comparision (#999)
This commit is contained in:
parent
c00b5edaf7
commit
bf92c6b2e9
@ -40,10 +40,6 @@ 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)
|
||||
}
|
||||
@ -62,10 +58,6 @@ class GradeDetailsAdapter @Inject constructor() : BaseExpandableAdapter<Recycler
|
||||
val headerPosition = headers.indexOf(item)
|
||||
val itemPosition = items.indexOf(item)
|
||||
|
||||
if (headerPosition == NO_POSITION || itemPosition == NO_POSITION) {
|
||||
Timber.e("Invalid update header positions! Header: $headerPosition, item: $itemPosition")
|
||||
}
|
||||
|
||||
headers[headerPosition] = item
|
||||
items[itemPosition] = item
|
||||
notifyItemChanged(itemPosition)
|
||||
|
@ -14,6 +14,7 @@ data class GradeDetailsHeader(
|
||||
val subject: String,
|
||||
val average: Double?,
|
||||
val pointsSum: String?,
|
||||
var newGrades: Int,
|
||||
val grades: List<GradeDetailsItem>
|
||||
)
|
||||
) {
|
||||
var newGrades = 0
|
||||
}
|
||||
|
@ -213,9 +213,10 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
subject = subject,
|
||||
average = average,
|
||||
pointsSum = points,
|
||||
newGrades = grades.filter { grade -> !grade.isRead }.size,
|
||||
grades = subItems
|
||||
), ViewType.HEADER)) + if (preferencesRepository.isGradeExpandable) emptyList() else subItems
|
||||
).apply {
|
||||
newGrades = grades.filter { grade -> !grade.isRead }.size
|
||||
}, ViewType.HEADER)) + if (preferencesRepository.isGradeExpandable) emptyList() else subItems
|
||||
}.flatten()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user