Verification: migrate to Epoxy - Disable item animation

This commit is contained in:
Benoit Marty 2020-01-15 12:36:09 +01:00 committed by Valere
parent cd1665a8e8
commit a8e81d95cf
7 changed files with 14 additions and 14 deletions

View file

@ -28,12 +28,17 @@ fun RecyclerView.configureWith(epoxyController: EpoxyController,
itemAnimator: RecyclerView.ItemAnimator? = null,
viewPool: RecyclerView.RecycledViewPool? = null,
showDivider: Boolean = false,
hasFixedSize: Boolean = true) {
hasFixedSize: Boolean = true,
disableItemAnimation: Boolean = false) {
layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false).apply {
recycleChildrenOnDetach = viewPool != null
}
setRecycledViewPool(viewPool)
if (disableItemAnimation) {
this.itemAnimator = null
} else {
itemAnimator?.let { this.itemAnimator = it }
}
if (showDivider) {
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
}

View file

@ -98,10 +98,9 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
}
private fun setupRecyclerView() {
// Don't activate animation as we might have way to much item animation when filtering
recyclerView.itemAnimator = null
knownUsersController.callback = this
recyclerView.configureWith(knownUsersController)
// Don't activate animation as we might have way to much item animation when filtering
recyclerView.configureWith(knownUsersController, disableItemAnimation = true)
}
private fun setupFilterView() {

View file

@ -60,7 +60,7 @@ class VerificationConclusionFragment @Inject constructor(
}
private fun setupRecyclerView() {
bottomSheetVerificationRecyclerView.configureWith(controller, hasFixedSize = false)
bottomSheetVerificationRecyclerView.configureWith(controller, hasFixedSize = false, disableItemAnimation = true)
controller.listener = this
}

View file

@ -53,7 +53,7 @@ class VerificationEmojiCodeFragment @Inject constructor(
}
private fun setupRecyclerView() {
bottomSheetVerificationRecyclerView.configureWith(controller, hasFixedSize = false)
bottomSheetVerificationRecyclerView.configureWith(controller, hasFixedSize = false, disableItemAnimation = true)
controller.listener = this
}

View file

@ -53,7 +53,7 @@ class VerificationRequestFragment @Inject constructor(
}
private fun setupRecyclerView() {
bottomSheetVerificationRecyclerView.configureWith(controller, hasFixedSize = false)
bottomSheetVerificationRecyclerView.configureWith(controller, hasFixedSize = false, disableItemAnimation = true)
controller.listener = this
}

View file

@ -54,9 +54,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
sharedActionViewModel = activityViewModelProvider.get(MessageSharedActionViewModel::class.java)
recyclerView.configureWith(messageActionsEpoxyController, hasFixedSize = false)
// Disable item animation
recyclerView.itemAnimator = null
recyclerView.configureWith(messageActionsEpoxyController, hasFixedSize = false, disableItemAnimation = true)
messageActionsEpoxyController.listener = this
}

View file

@ -70,9 +70,7 @@ class RoomListQuickActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), R
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
sharedActionViewModel = activityViewModelProvider.get(RoomListQuickActionsSharedActionViewModel::class.java)
recyclerView.configureWith(roomListActionsEpoxyController, viewPool = sharedViewPool, hasFixedSize = false)
// Disable item animation
recyclerView.itemAnimator = null
recyclerView.configureWith(roomListActionsEpoxyController, viewPool = sharedViewPool, hasFixedSize = false, disableItemAnimation = true)
roomListActionsEpoxyController.listener = this
}