From 22955e6b3495fc4ebf7de78ec203ebcdb3f0d65e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 13 May 2020 23:52:47 +0200 Subject: [PATCH] Use debouncedClicks every where, for faster UI (it uses throttleFirst operator instead of debounce) --- .../crypto/keysbackup/setup/KeysBackupSetupStep3Fragment.kt | 2 +- .../java/im/vector/riotx/features/home/HomeDetailFragment.kt | 2 +- .../java/im/vector/riotx/features/home/HomeDrawerFragment.kt | 4 ++-- .../riotx/features/home/room/detail/RoomDetailFragment.kt | 4 ++-- .../vector/riotx/features/home/room/list/RoomListFragment.kt | 4 ++-- .../riotx/features/roomdirectory/PublicRoomsFragment.kt | 2 +- .../features/roomdirectory/createroom/CreateRoomFragment.kt | 2 +- .../VectorSettingsNotificationsTroubleshootFragment.kt | 4 ++-- .../account/deactivation/DeactivateAccountFragment.kt | 2 +- .../vector/riotx/features/userdirectory/KnownUsersFragment.kt | 4 ++-- .../riotx/features/userdirectory/UserDirectoryFragment.kt | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/setup/KeysBackupSetupStep3Fragment.kt b/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/setup/KeysBackupSetupStep3Fragment.kt index 9175d6c081..1478b99d3b 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/setup/KeysBackupSetupStep3Fragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/setup/KeysBackupSetupStep3Fragment.kt @@ -123,7 +123,7 @@ class KeysBackupSetupStep3Fragment @Inject constructor() : VectorBaseFragment() .joinToString(" ") } - it.setOnClickListener { + it.debouncedClicks { copyToClipboard(activity!!, recoveryKey) } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt index 1357b30413..b17fb87f50 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt @@ -209,7 +209,7 @@ class HomeDetailFragment @Inject constructor( parentActivity.configure(groupToolbar) } groupToolbar.title = "" - groupToolbarAvatarImageView.setOnClickListener { + groupToolbarAvatarImageView.debouncedClicks { sharedActionViewModel.post(HomeActivitySharedAction.OpenDrawer) } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDrawerFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDrawerFragment.kt index a8373797c6..3439b1793c 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDrawerFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDrawerFragment.kt @@ -53,13 +53,13 @@ class HomeDrawerFragment @Inject constructor( homeDrawerUserIdView.text = user.userId } } - homeDrawerHeaderSettingsView.setOnClickListener { + homeDrawerHeaderSettingsView.debouncedClicks { sharedActionViewModel.post(HomeActivitySharedAction.CloseDrawer) navigator.openSettings(requireActivity()) } // Debug menu - homeDrawerHeaderDebugView.setOnClickListener { + homeDrawerHeaderDebugView.debouncedClicks { sharedActionViewModel.post(HomeActivitySharedAction.CloseDrawer) navigator.openDebug(requireActivity()) } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index f348e0612a..079a2927d7 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -264,7 +264,7 @@ class RoomDetailFragment @Inject constructor( setupNotificationView() setupJumpToReadMarkerView() setupJumpToBottomView() - roomToolbarContentView.setOnClickListener { + roomToolbarContentView.debouncedClicks { navigator.openRoomProfile(requireActivity(), roomDetailArgs.roomId) } roomDetailViewModel.subscribe { renderState(it) } @@ -348,7 +348,7 @@ class RoomDetailFragment @Inject constructor( private fun setupJumpToBottomView() { jumpToBottomView.visibility = View.INVISIBLE - jumpToBottomView.setOnClickListener { + jumpToBottomView.debouncedClicks { roomDetailViewModel.handle(RoomDetailAction.ExitTrackingUnreadMessagesState) jumpToBottomView.visibility = View.INVISIBLE if (!roomDetailViewModel.timeline.isLive) { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListFragment.kt index 9c606de3b4..1484e8009b 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListFragment.kt @@ -142,10 +142,10 @@ class RoomListFragment @Inject constructor( else -> Unit // No button in this mode } - createChatRoomButton.setOnClickListener { + createChatRoomButton.debouncedClicks { createDirectChat() } - createGroupRoomButton.setOnClickListener { + createGroupRoomButton.debouncedClicks { openRoomDirectory() } diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt index e466c2311f..a75479275b 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt @@ -71,7 +71,7 @@ class PublicRoomsFragment @Inject constructor( } .disposeOnDestroyView() - publicRoomsCreateNewRoom.setOnClickListener { + publicRoomsCreateNewRoom.debouncedClicks { sharedActionViewModel.post(RoomDirectorySharedAction.CreateRoom) } diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/createroom/CreateRoomFragment.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/createroom/CreateRoomFragment.kt index 827db96783..7956f2fd9e 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/createroom/CreateRoomFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/createroom/CreateRoomFragment.kt @@ -46,7 +46,7 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C vectorBaseActivity.setSupportActionBar(createRoomToolbar) sharedActionViewModel = activityViewModelProvider.get(RoomDirectorySharedActionViewModel::class.java) setupRecyclerView() - createRoomClose.setOnClickListener { + createRoomClose.debouncedClicks { sharedActionViewModel.post(RoomDirectorySharedAction.Back) } } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationsTroubleshootFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationsTroubleshootFragment.kt index 3f69b5880e..04908e166f 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationsTroubleshootFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationsTroubleshootFragment.kt @@ -71,11 +71,11 @@ class VectorSettingsNotificationsTroubleshootFragment @Inject constructor( layoutManager.orientation) mRecyclerView.addItemDecoration(dividerItemDecoration) - mSummaryButton.setOnClickListener { + mSummaryButton.debouncedClicks { bugReporter.openBugReportScreen(activity!!) } - mRunButton.setOnClickListener { + mRunButton.debouncedClicks { testManager?.retry() } startUI() diff --git a/vector/src/main/java/im/vector/riotx/features/settings/account/deactivation/DeactivateAccountFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/account/deactivation/DeactivateAccountFragment.kt index f5130d5e00..8a8a5fa4e4 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/account/deactivation/DeactivateAccountFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/account/deactivation/DeactivateAccountFragment.kt @@ -80,7 +80,7 @@ class DeactivateAccountFragment @Inject constructor( viewModel.handle(DeactivateAccountAction.TogglePassword) } - deactivateAccountSubmit.setOnClickListener { + deactivateAccountSubmit.debouncedClicks { viewModel.handle(DeactivateAccountAction.DeactivateAccount( deactivateAccountPassword.text.toString(), deactivateAccountEraseCheckbox.isChecked)) diff --git a/vector/src/main/java/im/vector/riotx/features/userdirectory/KnownUsersFragment.kt b/vector/src/main/java/im/vector/riotx/features/userdirectory/KnownUsersFragment.kt index 78482e0b54..42dd46bd01 100644 --- a/vector/src/main/java/im/vector/riotx/features/userdirectory/KnownUsersFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/userdirectory/KnownUsersFragment.kt @@ -91,7 +91,7 @@ class KnownUsersFragment @Inject constructor( } private fun setupAddByMatrixIdView() { - addByMatrixId.setOnClickListener { + addByMatrixId.debouncedClicks { sharedActionViewModel.post(UserDirectorySharedAction.OpenUsersDirectory) } } @@ -122,7 +122,7 @@ class KnownUsersFragment @Inject constructor( } private fun setupCloseView() { - knownUsersClose.setOnClickListener { + knownUsersClose.debouncedClicks { requireActivity().finish() } } diff --git a/vector/src/main/java/im/vector/riotx/features/userdirectory/UserDirectoryFragment.kt b/vector/src/main/java/im/vector/riotx/features/userdirectory/UserDirectoryFragment.kt index 28aa2d433b..12de191b54 100644 --- a/vector/src/main/java/im/vector/riotx/features/userdirectory/UserDirectoryFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/userdirectory/UserDirectoryFragment.kt @@ -73,7 +73,7 @@ class UserDirectoryFragment @Inject constructor( } private fun setupCloseView() { - userDirectoryClose.setOnClickListener { + userDirectoryClose.debouncedClicks { sharedActionViewModel.post(UserDirectorySharedAction.GoBack) } }