mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-09 08:38:43 +01:00
Ensure unique ids for subspaces
When you have two root spaces with the same space as subspace, and you expand both root spaces, you end up with two times the same id in the list. This has two problems: - The expand animation is slightly broken, if you expand the second root space first and then the first one - If you select one of these items with same id, the app crashes: java.lang.IllegalStateException: Two different ViewHolders have the same stable ID. Stable IDs in your adapter MUST BE unique and SHOULD NOT change. As solution, just prefix the epoxy item ids with the parent spaces. Change-Id: I93afc5499404cc09dbfa0fbe963558e5f4595233
This commit is contained in:
parent
fa79bc3e38
commit
94b9a51b9e
@ -177,7 +177,7 @@ class SpaceSummaryController @Inject constructor(
|
||||
if (hasChildren && expanded) {
|
||||
// it's expanded
|
||||
subSpaces?.forEach { child ->
|
||||
buildSubSpace(summaries, expandedStates, selected, child, 1, 3)
|
||||
buildSubSpace(groupSummary.roomId, summaries, expandedStates, selected, child, 1, 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,7 +188,8 @@ class SpaceSummaryController @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildSubSpace(summaries: List<RoomSummary>?,
|
||||
private fun buildSubSpace(idPrefix: String,
|
||||
summaries: List<RoomSummary>?,
|
||||
expandedStates: Map<String, Boolean>,
|
||||
selected: RoomGroupingMethod,
|
||||
info: SpaceChildInfo, currentDepth: Int, maxDepth: Int) {
|
||||
@ -204,9 +205,11 @@ class SpaceSummaryController @Inject constructor(
|
||||
|
||||
val useAggregateCounts = vectorPreferences.aggregateUnreadRoomCounts()
|
||||
|
||||
val id = "$idPrefix:${childSummary.roomId}"
|
||||
|
||||
subSpaceSummaryItem {
|
||||
avatarRenderer(host.avatarRenderer)
|
||||
id(childSummary.roomId)
|
||||
id(id)
|
||||
hasChildren(!subSpaces.isNullOrEmpty())
|
||||
selected(isSelected)
|
||||
expanded(expanded)
|
||||
@ -227,7 +230,7 @@ class SpaceSummaryController @Inject constructor(
|
||||
|
||||
if (expanded) {
|
||||
subSpaces?.forEach {
|
||||
buildSubSpace(summaries, expandedStates, selected, it, currentDepth + 1, maxDepth)
|
||||
buildSubSpace(id, summaries, expandedStates, selected, it, currentDepth + 1, maxDepth)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user