Skip to content

Commit

Permalink
Removed duplicate code and added it to a function- addListItems
Browse files Browse the repository at this point in the history
Bug: None

Change-Id: I93aa14ff5791838b8955964e3f1ca34234b165f4
Signed-off-by: Himadri Agrawal <h2.agrawal@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4899740
Reviewed-by: Brandon Wylie <wylieb@chromium.org>
Commit-Queue: Shubham Gupta <shubh.gupta@samsung.com>
Cr-Commit-Position: refs/heads/main@{#1209852}
  • Loading branch information
Himadri Agrawal authored and Chromium LUCI CQ committed Oct 14, 2023
1 parent 8ce1cdc commit f119a4f
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,8 @@ private ModelList getItems() {
: R.string.reading_list_mark_as_read,
0, 0));
}
listItems.add(buildMenuListItem(R.string.bookmark_item_select, 0, 0));
listItems.add(buildMenuListItem(R.string.bookmark_item_delete, 0, 0));
listItems.add(buildMenuListItem(R.string.bookmark_item_edit, 0, 0));
listItems.add(buildMenuListItem(R.string.bookmark_item_move, 0, 0));
} else {
listItems.add(buildMenuListItem(R.string.bookmark_item_select, 0, 0));
listItems.add(buildMenuListItem(R.string.bookmark_item_edit, 0, 0));
listItems.add(buildMenuListItem(R.string.bookmark_item_move, 0, 0, canMove));
listItems.add(buildMenuListItem(R.string.bookmark_item_delete, 0, 0));
}
addListItems(listItems, canMove);

if (mDelegate.getCurrentUiMode() == BookmarkUiMode.SEARCHING) {
listItems.add(buildMenuListItem(R.string.bookmark_show_in_folder, 0, 0));
Expand All @@ -256,6 +248,13 @@ private ModelList getItems() {
return listItems;
}

private void addListItems(ModelList listItems, boolean canMove) {
listItems.add(buildMenuListItem(R.string.bookmark_item_select, 0, 0));
listItems.add(buildMenuListItem(R.string.bookmark_item_move, 0, 0, canMove));
listItems.add(buildMenuListItem(R.string.bookmark_item_edit, 0, 0));
listItems.add(buildMenuListItem(R.string.bookmark_item_delete, 0, 0));
}

private ListMenu getListMenu() {
ModelList listItems = getItems();
ListMenu.Delegate delegate = item -> {
Expand Down

0 comments on commit f119a4f

Please sign in to comment.