From 6787d450e8a66b90055a74f67c6285392849ae06 Mon Sep 17 00:00:00 2001 From: Jesse Aboh Date: Sun, 17 May 2015 18:53:15 -0400 Subject: [PATCH] Add ability to add dividers by code via groupId --- .../com/cocosw/bottomsheet/BottomSheet.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/library/src/main/java/com/cocosw/bottomsheet/BottomSheet.java b/library/src/main/java/com/cocosw/bottomsheet/BottomSheet.java index 0fd5cbe..27777b4 100755 --- a/library/src/main/java/com/cocosw/bottomsheet/BottomSheet.java +++ b/library/src/main/java/com/cocosw/bottomsheet/BottomSheet.java @@ -668,6 +668,21 @@ public Builder sheet(int id, @DrawableRes int iconRes, @StringRes int textRes) { menu.add(item); return this; } + /** + * Add one item into BottomSheet + * + * @param id ID of item + * @param iconRes icon resource + * @param groupId used to add dividers to section with different Ids, default is 0. + * @param textRes text resource + * @return This Builder object to allow for chaining of calls to set methods + */ + public Builder sheet(int id,int groupId, @DrawableRes int iconRes, @StringRes int textRes) { + ActionMenuItem item = new ActionMenuItem(context, groupId, id, 0, 0, context.getText(textRes)); + item.setIcon(iconRes); + menu.add(item); + return this; + } /** * Add one item into BottomSheet @@ -683,6 +698,21 @@ public Builder sheet(int id, @NonNull Drawable icon, @NonNull CharSequence text) menu.add(item); return this; } + /** + * Add one item into BottomSheet + * + * @param id ID of item + * @param icon icon + * @param groupId used to add dividers to section with different Ids, default is 0. + * @param text text + * @return This Builder object to allow for chaining of calls to set methods + */ + public Builder sheet(int id,int groupId, @NonNull Drawable icon, @NonNull CharSequence text) { + ActionMenuItem item = new ActionMenuItem(context, groupId, id, 0, 0, text); + item.setIcon(icon); + menu.add(item); + return this; + } /** * Add one item without icon into BottomSheet @@ -696,6 +726,19 @@ public Builder sheet(int id, @StringRes int textRes) { return this; } + /** + * Add one item without icon into BottomSheet + * + * @param groupId used to add dividers to section with different Ids, default is 0. + * @param id ID of item + * @param textRes text resource + * @return This Builder object to allow for chaining of calls to set methods + */ + public Builder sheetWithSection(int groupId, int id, @StringRes int textRes) { + menu.add(groupId, id, 0, textRes); + return this; + } + /** * Add one item without icon into BottomSheet * @@ -708,6 +751,19 @@ public Builder sheet(int id, @NonNull CharSequence text) { return this; } + /** + * Add one item without icon into BottomSheet + * + * @param groupId used to add dividers to section with different Ids, default is 0. + * @param id ID of item + * @param text text + * @return This Builder object to allow for chaining of calls to set methods + */ + public Builder sheetWithSection(int groupId, int id, @NonNull CharSequence text) { + menu.add(groupId, id, 0, text); + return this; + } + /** * Set title for BottomSheet *