Fix persisting room sections
Change-Id: Ia39e84c00bad8777605c237534cb6f13f5741fe0
This commit is contained in:
parent
bbc856ffa3
commit
2d710923a1
|
@ -101,6 +101,7 @@ class RoomListFragment :
|
||||||
private lateinit var stateRestorer: LayoutManagerStateRestorer
|
private lateinit var stateRestorer: LayoutManagerStateRestorer
|
||||||
|
|
||||||
private var expandStatusSpaceId: String? = null
|
private var expandStatusSpaceId: String? = null
|
||||||
|
private var lastLoadForcedExpand: Boolean = false
|
||||||
|
|
||||||
val dbgId = System.identityHashCode(this)
|
val dbgId = System.identityHashCode(this)
|
||||||
private val viewPagerDimber = Dimber("Home pager rlf/$dbgId", DbgUtil.DBG_VIEW_PAGER)
|
private val viewPagerDimber = Dimber("Home pager rlf/$dbgId", DbgUtil.DBG_VIEW_PAGER)
|
||||||
|
@ -240,9 +241,13 @@ class RoomListFragment :
|
||||||
|
|
||||||
private fun refreshCollapseStates() {
|
private fun refreshCollapseStates() {
|
||||||
val sectionsCount = adapterInfosList.count { !it.sectionHeaderAdapter.roomsSectionData.isHidden }
|
val sectionsCount = adapterInfosList.count { !it.sectionHeaderAdapter.roomsSectionData.isHidden }
|
||||||
|
val isRoomSectionCollapsable = sectionsCount > 1
|
||||||
|
if (lastLoadForcedExpand && isRoomSectionCollapsable) {
|
||||||
|
loadExpandStatus()
|
||||||
|
}
|
||||||
|
lastLoadForcedExpand = !isRoomSectionCollapsable
|
||||||
roomListViewModel.sections.forEachIndexed { index, roomsSection ->
|
roomListViewModel.sections.forEachIndexed { index, roomsSection ->
|
||||||
val actualBlock = adapterInfosList[index]
|
val actualBlock = adapterInfosList[index]
|
||||||
val isRoomSectionCollapsable = sectionsCount > 1
|
|
||||||
val isRoomSectionExpanded = roomsSection.isExpanded.value.orTrue()
|
val isRoomSectionExpanded = roomsSection.isExpanded.value.orTrue()
|
||||||
if (actualBlock.section.isExpanded && !isRoomSectionExpanded) {
|
if (actualBlock.section.isExpanded && !isRoomSectionExpanded) {
|
||||||
// mark controller as collapsed
|
// mark controller as collapsed
|
||||||
|
@ -705,6 +710,8 @@ class RoomListFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun persistExpandStatus() {
|
private fun persistExpandStatus() {
|
||||||
|
// No need to persist force-expanded values
|
||||||
|
if (lastLoadForcedExpand) return
|
||||||
val spEdit = getSharedPreferences()?.edit() ?: return
|
val spEdit = getSharedPreferences()?.edit() ?: return
|
||||||
roomListViewModel.sections.forEach{section ->
|
roomListViewModel.sections.forEach{section ->
|
||||||
val isExpanded = section.isExpanded.value
|
val isExpanded = section.isExpanded.value
|
||||||
|
|
Loading…
Reference in New Issue