From 1206107a73a3300a1a0c526e966decc17f6534c7 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 11 Jun 2019 15:43:40 +0200 Subject: [PATCH] Fix / visibility bug after scroll + refine animation --- .../home/room/list/RoomListFragment.kt | 35 +++++++++--------- .../home/room/list/widget/FabMenuView.kt | 13 ++++--- .../main/res/xml/motion_scene_fab_menu.xml | 36 +++++++++++++++++-- 3 files changed, 61 insertions(+), 23 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListFragment.kt index e354be2f..e7b8b837 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomListFragment.kt @@ -93,25 +93,26 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback, O } // Hide FAB when list is scrolling - epoxyRecyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { - override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { - createChatFabMenu.removeCallbacks(showFabRunnable) + epoxyRecyclerView.addOnScrollListener( + object : RecyclerView.OnScrollListener() { + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + createChatFabMenu.removeCallbacks(showFabRunnable) - when (newState) { - RecyclerView.SCROLL_STATE_IDLE -> { - createChatFabMenu.postDelayed(showFabRunnable, 1000) - } - RecyclerView.SCROLL_STATE_DRAGGING, - RecyclerView.SCROLL_STATE_SETTLING -> { - when (roomListParams.displayMode) { - DisplayMode.HOME -> createChatFabMenu.hide() - DisplayMode.PEOPLE -> createChatRoomButton.hide() - else -> createGroupRoomButton.hide() + when (newState) { + RecyclerView.SCROLL_STATE_IDLE -> { + createChatFabMenu.postDelayed(showFabRunnable, 1000) + } + RecyclerView.SCROLL_STATE_DRAGGING, + RecyclerView.SCROLL_STATE_SETTLING -> { + when (roomListParams.displayMode) { + DisplayMode.HOME -> createChatFabMenu.hide() + DisplayMode.PEOPLE -> createChatRoomButton.hide() + else -> createGroupRoomButton.hide() + } + } } } - } - } - }) + }) } @@ -220,7 +221,7 @@ class RoomListFragment : VectorBaseFragment(), RoomSummaryController.Callback, O return super.onBackPressed() } - // RoomSummaryController.Callback ************************************************************** +// RoomSummaryController.Callback ************************************************************** override fun onRoomSelected(room: RoomSummary) { roomListViewModel.accept(RoomListActions.SelectRoom(room)) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/list/widget/FabMenuView.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/list/widget/FabMenuView.kt index 7b8fb78c..9210e7ac 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/list/widget/FabMenuView.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/list/widget/FabMenuView.kt @@ -19,6 +19,8 @@ package im.vector.riotredesign.features.home.room.list.widget import android.content.Context import android.util.AttributeSet import androidx.constraintlayout.motion.widget.MotionLayout +import androidx.core.view.isVisible +import com.google.android.material.floatingactionbutton.FloatingActionButton import im.vector.riotredesign.R import im.vector.riotredesign.features.themes.ThemeUtils import kotlinx.android.synthetic.main.motion_fab_menu_merge.view.* @@ -62,14 +64,17 @@ class FabMenuView @JvmOverloads constructor(context: Context, attrs: AttributeSe } fun show() { - // Ensure visibility is well restored - // FIXME It does not work, FAB is not visible, alpha is 0... And cannot set it to 1 - + isVisible = true createRoomButton.show() } fun hide() { - createRoomButton.hide() + createRoomButton.hide(object : FloatingActionButton.OnVisibilityChangedListener() { + override fun onHidden(fab: FloatingActionButton?) { + super.onHidden(fab) + isVisible = false + } + }) } private fun closeFabMenu() { diff --git a/vector/src/main/res/xml/motion_scene_fab_menu.xml b/vector/src/main/res/xml/motion_scene_fab_menu.xml index fc363cfc..5cbf8bcd 100644 --- a/vector/src/main/res/xml/motion_scene_fab_menu.xml +++ b/vector/src/main/res/xml/motion_scene_fab_menu.xml @@ -6,12 +6,44 @@ + motion:motionInterpolator="easeInOut" + motion:duration="300"> + + + + + + + + + + + @@ -96,7 +128,7 @@ - +