mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-18 04:50:08 +03:00
Home pager: avoid re-applying space id that we persisted onPause
Change-Id: I101de2548db20747e753c4f6401b9bf82fab31d7
This commit is contained in:
parent
fb68ba92fa
commit
23f4f72ba3
1 changed files with 11 additions and 0 deletions
|
@ -70,6 +70,8 @@ import timber.log.Timber
|
|||
import javax.inject.Inject
|
||||
import kotlin.math.abs
|
||||
|
||||
private const val NO_PENDING_SPACE_ID = "de.spiritcroc.riotx.SPACE_ID_NONE"
|
||||
|
||||
class HomeDetailFragment @Inject constructor(
|
||||
private val avatarRenderer: AvatarRenderer,
|
||||
private val colorProvider: ColorProvider,
|
||||
|
@ -107,6 +109,7 @@ class HomeDetailFragment @Inject constructor(
|
|||
private var pagerSpaces: List<String?>? = null
|
||||
private var pagerTab: HomeTab? = null
|
||||
private var pagerPagingEnabled: Boolean = false
|
||||
private var pendingSpaceId: String? = NO_PENDING_SPACE_ID
|
||||
|
||||
override fun getMenuRes() = R.menu.room_list
|
||||
|
||||
|
@ -294,6 +297,8 @@ class HomeDetailFragment @Inject constructor(
|
|||
|
||||
// Persist swiped
|
||||
appStateHandler.persistSelectedSpace()
|
||||
// Remember the persisted value, so we can ignore it once the listeners are running again
|
||||
pendingSpaceId = getSpaceIdForPageIndex(views.roomListContainerPager.currentItem)
|
||||
}
|
||||
|
||||
private fun checkNotificationTabStatus(enableDialPad: Boolean? = null) {
|
||||
|
@ -556,6 +561,11 @@ class HomeDetailFragment @Inject constructor(
|
|||
if (!changed) {
|
||||
if (pagingEnabled) {
|
||||
// No need to re-setup pager, just check for selected page
|
||||
// If it's a pendingSpaceId, we want to ignore it too, since we created it
|
||||
if (pendingSpaceId == selectedSpaceId) {
|
||||
pendingSpaceId = NO_PENDING_SPACE_ID
|
||||
return
|
||||
}
|
||||
if (selectedIndex != null) {
|
||||
if (selectedIndex != views.roomListContainerPager.currentItem) {
|
||||
// post() mitigates a case where we could end up in an endless loop circling around the same few spaces
|
||||
|
@ -588,6 +598,7 @@ class HomeDetailFragment @Inject constructor(
|
|||
pagerTab = tab
|
||||
pagerPagingEnabled = pagingEnabled
|
||||
initialPageSelected = false
|
||||
pendingSpaceId = NO_PENDING_SPACE_ID
|
||||
|
||||
// OFFSCREEN_PAGE_LIMIT_DEFAULT: default recyclerview caching mechanism instead of explicit fixed prefetching
|
||||
//views.roomListContainerPager.offscreenPageLimit = 2
|
||||
|
|
Loading…
Add table
Reference in a new issue