- override fun onItemCheckedStateChanged(mode: ActionMode, position: Int, id: Long, checked: Boolean) {
- // Get the number of selected bookmarks.
- val numberOfSelectedBookmarks = bookmarksListView.checkedItemCount
-
- // Only process commands if at least one bookmark is selected. Otherwise, a context menu with 0 selected bookmarks is briefly displayed.
- if (numberOfSelectedBookmarks > 0) {
- // Adjust the action mode and the menu according to the number of selected bookmarks.
- if (numberOfSelectedBookmarks == 1) { // One bookmark is selected.
- // Show the applicable menu items.
- moveBookmarkUpMenuItem.isVisible = true
- moveBookmarkDownMenuItem.isVisible = true
- editBookmarkMenuItem.isVisible = true
-
- // Update the enabled status of the move icons.
- updateMoveIcons()
- } else { // More than one bookmark is selected.
- // Hide non-applicable `MenuItems`.
- moveBookmarkUpMenuItem.isVisible = false
- moveBookmarkDownMenuItem.isVisible = false
- editBookmarkMenuItem.isVisible = false
- }
+ override fun onItemCheckedStateChanged(actionMode: ActionMode, position: Int, id: Long, checked: Boolean) {
+ // Only update the UI if not checking many bookmarks. In that case, the flag will be reset on the last bookmark so the UI is only updated once.
+ if (!checkingManyBookmarks) {
+ // Get the number of selected bookmarks.
+ val numberOfSelectedBookmarks = bookmarksListView.checkedItemCount
+
+ // Only process commands if at least one bookmark is selected. Otherwise, a context menu with 0 selected bookmarks is briefly displayed.
+ if (numberOfSelectedBookmarks > 0) {
+ // Adjust the action mode and the menu according to the number of selected bookmarks.
+ if (numberOfSelectedBookmarks == 1) { // One bookmark is selected.
+ // Update the move menu items if the bookmarks are not sorted alphabetically.
+ if (!sortBookmarksAlphabetically) {
+ moveBookmarkUpMenuItem.isVisible = true
+ moveBookmarkDownMenuItem.isVisible = true
+ }
+
+ // Show the edit bookmark menu item.
+ editBookmarkMenuItem.isVisible = true
+
+ // Update the enabled status of the move icons if the bookmarks are not sorted alphabetically.
+ if (!sortBookmarksAlphabetically)
+ updateMoveIcons()
+ } else { // More than one bookmark is selected.
+ // Update the move menu items if the bookmarks are not sorted alphabetically.
+ if (!sortBookmarksAlphabetically) {
+ moveBookmarkUpMenuItem.isVisible = false
+ moveBookmarkDownMenuItem.isVisible = false
+ }