/*
- * Copyright 2016-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2016-2023 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
*
// Adjust the ActionMode and the menu according to the number of selected bookmarks.
if (numberOfSelectedBookmarks == 1) { // One bookmark is selected.
// List the number of selected bookmarks in the subtitle.
- mode.setSubtitle(getString(R.string.selected) + " 1");
+ mode.setSubtitle(getString(R.string.selected) + "1");
// Show the `Move Up`, `Move Down`, and `Edit` options.
moveBookmarkUpMenuItem.setVisible(true);
updateMoveIcons();
} else { // More than one bookmark is selected.
// List the number of selected bookmarks in the subtitle.
- mode.setSubtitle(getString(R.string.selected) + " " + numberOfSelectedBookmarks);
+ mode.setSubtitle(getString(R.string.selected) + numberOfSelectedBookmarks);
// Hide non-applicable `MenuItems`.
moveBookmarkUpMenuItem.setVisible(false);
bookmarksCursorAdapter.changeCursor(bookmarksCursor);
// Create a Snackbar with the number of deleted bookmarks.
- bookmarksDeletedSnackbar = Snackbar.make(findViewById(R.id.bookmarks_coordinatorlayout), getString(R.string.bookmarks_deleted) + " " + numberOfBookmarksToDelete,
+ bookmarksDeletedSnackbar = Snackbar.make(findViewById(R.id.bookmarks_coordinatorlayout), getString(R.string.bookmarks_deleted) + numberOfBookmarksToDelete,
Snackbar.LENGTH_LONG)
.setAction(R.string.undo, view -> {
// Do nothing because everything will be handled by `onDismissed()` below.
// Get the checked bookmarks array list.
ArrayList<Integer> checkedBookmarksArrayList = savedInstanceState.getIntegerArrayList(CHECKED_BOOKMARKS_ARRAY_LIST);
- // Check each previously checked bookmark in the list view. When the minimum API >= 24 a `forEach()` command can be used instead.
- if (checkedBookmarksArrayList != null) {
- for (int i = 0; i < checkedBookmarksArrayList.size(); i++) {
- bookmarksListView.setItemChecked(checkedBookmarksArrayList.get(i), true);
- }
- }
+ // Check each previously checked bookmark in the list view.
+ if (checkedBookmarksArrayList != null)
+ checkedBookmarksArrayList.forEach((position) -> bookmarksListView.setItemChecked(position, true));
});
}