Skip to content

Commit

Permalink
Merge pull request soarcn#82 from anatolyrc/master
Browse files Browse the repository at this point in the history
follow Menu semantics when the item id does not exist
  • Loading branch information
soarcn committed Aug 27, 2015
2 parents 19163a1 + 16551fa commit 79a291b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions library/src/main/java/com/cocosw/bottomsheet/ActionMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ private int findItemIndex(int id) {
}

public MenuItem findItem(int id) {
return mItems.get(findItemIndex(id));
final int index = findItemIndex(id);
if (index < 0) {
return null;
}

return mItems.get(index);
}

public MenuItem getItem(int index) {
Expand Down Expand Up @@ -258,7 +263,12 @@ public void removeGroup(int groupId) {
}

public void removeItem(int id) {
mItems.remove(findItemIndex(id));
final int index = findItemIndex(id);
if (index < 0) {
return;
}

mItems.remove(index);
}

public void setGroupCheckable(int group, boolean checkable,
Expand Down

0 comments on commit 79a291b

Please sign in to comment.