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) {
|
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)
|
items[position] = GradeDetailsItem(grade, ViewType.ITEM)
|
||||||
notifyItemChanged(position)
|
notifyItemChanged(position)
|
||||||
}
|
}
|
||||||
@ -62,10 +58,6 @@ class GradeDetailsAdapter @Inject constructor() : BaseExpandableAdapter<Recycler
|
|||||||
val headerPosition = headers.indexOf(item)
|
val headerPosition = headers.indexOf(item)
|
||||||
val itemPosition = items.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
|
headers[headerPosition] = item
|
||||||
items[itemPosition] = item
|
items[itemPosition] = item
|
||||||
notifyItemChanged(itemPosition)
|
notifyItemChanged(itemPosition)
|
||||||
|
@ -14,6 +14,7 @@ data class GradeDetailsHeader(
|
|||||||
val subject: String,
|
val subject: String,
|
||||||
val average: Double?,
|
val average: Double?,
|
||||||
val pointsSum: String?,
|
val pointsSum: String?,
|
||||||
var newGrades: Int,
|
|
||||||
val grades: List<GradeDetailsItem>
|
val grades: List<GradeDetailsItem>
|
||||||
)
|
) {
|
||||||
|
var newGrades = 0
|
||||||
|
}
|
||||||
|
@ -213,9 +213,10 @@ class GradeDetailsPresenter @Inject constructor(
|
|||||||
subject = subject,
|
subject = subject,
|
||||||
average = average,
|
average = average,
|
||||||
pointsSum = points,
|
pointsSum = points,
|
||||||
newGrades = grades.filter { grade -> !grade.isRead }.size,
|
|
||||||
grades = subItems
|
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()
|
}.flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user