Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to add dividers by code via groupId #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions library/src/main/java/com/cocosw/bottomsheet/BottomSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
*
Expand All @@ -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
*
Expand Down