Update ViewPager debugging

Change-Id: I969a649335f069ddc68762975be8e8aad018a37d
This commit is contained in:
SpiritCroc 2022-04-07 16:16:13 +02:00
parent 48d632cce5
commit 66f5b5c771
2 changed files with 46 additions and 1 deletions

View file

@ -39,6 +39,7 @@ import com.airbnb.mvrx.withState
import im.vector.app.AppStateHandler import im.vector.app.AppStateHandler
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import de.spiritcroc.matrixsdk.util.DbgUtil import de.spiritcroc.matrixsdk.util.DbgUtil
import de.spiritcroc.matrixsdk.util.Dimber
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.epoxy.LayoutManagerStateRestorer import im.vector.app.core.epoxy.LayoutManagerStateRestorer
import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.cleanup
@ -99,6 +100,13 @@ class RoomListFragment @Inject constructor(
private var expandStatusSpaceId: String? = null private var expandStatusSpaceId: String? = null
val dbgId = System.identityHashCode(this)
private val viewPagerDimber = Dimber("Home pager rlf/$dbgId", DbgUtil.DBG_VIEW_PAGER)
init {
viewPagerDimber.i { "init rlf" }
}
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomListBinding { override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomListBinding {
return FragmentRoomListBinding.inflate(inflater, container, false) return FragmentRoomListBinding.inflate(inflater, container, false)
} }
@ -120,6 +128,7 @@ class RoomListFragment @Inject constructor(
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
viewPagerDimber.i { "onCreate rlf -> ${roomListParams.explicitSpaceId}" }
analyticsScreenName = when (roomListParams.displayMode) { analyticsScreenName = when (roomListParams.displayMode) {
RoomListDisplayMode.PEOPLE -> MobileScreen.ScreenName.People RoomListDisplayMode.PEOPLE -> MobileScreen.ScreenName.People
RoomListDisplayMode.ROOMS -> MobileScreen.ScreenName.Rooms RoomListDisplayMode.ROOMS -> MobileScreen.ScreenName.Rooms
@ -181,8 +190,31 @@ class RoomListFragment @Inject constructor(
if (DbgUtil.isDbgEnabled(DbgUtil.DBG_VIEW_PAGER)) { if (DbgUtil.isDbgEnabled(DbgUtil.DBG_VIEW_PAGER)) {
views.scRoomListDebugView.isVisible = true views.scRoomListDebugView.isVisible = true
withState(roomListViewModel) { withState(roomListViewModel) {
viewPagerDimber.i {
"dbgUpdate rlvm/${roomListViewModel.dbgId} explicit ${roomListParams.explicitSpaceId} expand $expandStatusSpaceId vm-space ${roomListViewModel.dbgExplicitSpaceId}"
}
val currentSpace = it.currentRoomGrouping.invoke()?.space() val currentSpace = it.currentRoomGrouping.invoke()?.space()
views.scRoomListDebugView.text = "explicit: ${roomListParams.explicitSpaceId}\nexpanded: $expandStatusSpaceId\ngrouping: ${currentSpace?.roomId} | ${currentSpace?.displayName}" var text = "rlf/$dbgId rlvm/${roomListViewModel.dbgId}\nexplicit: ${roomListParams.explicitSpaceId}"
if (currentSpace?.roomId != roomListParams.explicitSpaceId) {
text += "\ngrouping: ${currentSpace?.roomId}"
}
text += " | ${currentSpace?.displayName}"
/*
if (expandStatusSpaceId != roomListParams.explicitSpaceId) {
text += "\nexpanded: $expandStatusSpaceId"
}
*/
if (roomListViewModel.dbgExplicitSpaceId != roomListParams.explicitSpaceId) {
text += "\nmodel: ${roomListViewModel.dbgExplicitSpaceId}"
}
// Append text to previous text to maintain history
/*
val previousText = views.scRoomListDebugView.text.toString()
if (previousText.isNotEmpty() && !previousText.endsWith(text)) {
text = "$previousText\n...\n$text"
}
*/
views.scRoomListDebugView.text = text
} }
} else { } else {
views.scRoomListDebugView.isVisible = false views.scRoomListDebugView.isVisible = false

View file

@ -25,6 +25,8 @@ import com.airbnb.mvrx.Success
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import de.spiritcroc.matrixsdk.util.DbgUtil
import de.spiritcroc.matrixsdk.util.Dimber
import im.vector.app.AppStateHandler import im.vector.app.AppStateHandler
import im.vector.app.RoomGroupingMethod import im.vector.app.RoomGroupingMethod
import im.vector.app.core.di.MavericksAssistedViewModelFactory import im.vector.app.core.di.MavericksAssistedViewModelFactory
@ -70,6 +72,16 @@ class RoomListViewModel @AssistedInject constructor(
private val suggestedRoomJoiningState: MutableLiveData<Map<String, Async<Unit>>> = MutableLiveData(emptyMap()) private val suggestedRoomJoiningState: MutableLiveData<Map<String, Async<Unit>>> = MutableLiveData(emptyMap())
val dbgId = System.identityHashCode(this)
private val viewPagerDimber = Dimber("Home pager rlvm/$dbgId", DbgUtil.DBG_VIEW_PAGER)
// Look up the explicitSpaceId used for building sections for debugging purposes
val dbgExplicitSpaceId = initialState.explicitSpaceId
init {
viewPagerDimber.i { "init rlvm -> ${initialState.explicitSpaceId} | $dbgExplicitSpaceId" }
}
interface ActiveSpaceQueryUpdater { interface ActiveSpaceQueryUpdater {
fun updateForSpaceId(roomId: String?) fun updateForSpaceId(roomId: String?)
} }
@ -148,6 +160,7 @@ class RoomListViewModel @AssistedInject constructor(
} }
val sections: List<RoomsSection> by lazy { val sections: List<RoomsSection> by lazy {
viewPagerDimber.i { "Build sections for ${initialState.displayMode}, ${initialState.explicitSpaceId}" }
roomListSectionBuilder.buildSections(initialState.displayMode, initialState.explicitSpaceId) roomListSectionBuilder.buildSections(initialState.displayMode, initialState.explicitSpaceId)
} }