- // Instantiate `snackbarMessage`.
- String snackbarMessage;
-
- // Determine how many items are in the array and prepare an appropriate snackbar message.
- if (selectedBookmarksIdsLongArray.length == 1) {
- snackbarMessage = getString(R.string.one_bookmark_deleted);
- } else {
- // Prepare a snackbar according to the language.
- if (getString(R.string.android_asset_path).equals("ru")) { // The Russian translation is used.
- // Convert the number of selected bookmarks to a string.
- String numberOfBookmarksString = String.valueOf(selectedBookmarksIdsLongArray.length);
-
- // Russian follows rule #7 at <https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals>.
- if (numberOfBookmarksString.endsWith("1") && !numberOfBookmarksString.equals("11")) { // Ends in 1.
- snackbarMessage = numberOfBookmarksString + " " + getString(R.string.bookmarks_deleted_russian_ends_in_1);
- } else if ((numberOfBookmarksString.endsWith("2") || numberOfBookmarksString.endsWith("3") || numberOfBookmarksString.endsWith("4")) &&
- !numberOfBookmarksString.equals("12") && !numberOfBookmarksString.equals("13") && !numberOfBookmarksString.equals("14")) { // Ends in 2-4.
- snackbarMessage = numberOfBookmarksString + " " + getString(R.string.bookmarks_deleted_russian_ends_in_2);
- } else { // Everything else.
- snackbarMessage = numberOfBookmarksString + " " + getString(R.string.bookmarks_deleted_russian_everything_else);
- }
- } else { // Another language is used.
- snackbarMessage = selectedBookmarksIdsLongArray.length + " " + getString(R.string.bookmarks_deleted);
- }
- }
-
- // Show a SnackBar.
- bookmarksDeletedSnackbar = Snackbar.make(findViewById(R.id.bookmarks_coordinatorlayout), snackbarMessage, Snackbar.LENGTH_LONG)
+ // Create a Snackbar with the number of deleted bookmarks.
+ bookmarksDeletedSnackbar = Snackbar.make(findViewById(R.id.bookmarks_coordinatorlayout), getString(R.string.bookmarks_deleted) + " " + selectedBookmarksIdsLongArray.length,
+ Snackbar.LENGTH_LONG)