Add small fixes to BaseBottomSheetItem and SimpleBottomSheetItem

This commit is contained in:
Alexander Sytnyk 2018-02-26 18:54:33 +02:00
parent 5e3a6135b7
commit ba2819cb7c
2 changed files with 66 additions and 58 deletions

View file

@ -7,19 +7,19 @@ public class BaseBottomSheetItem {
private View customView;
@LayoutRes
private int layoutResId;
private boolean clickable = true;
private int layoutId;
private boolean disabled;
private View.OnClickListener onClickListener;
private int position = -1;
public BaseBottomSheetItem(View customView,
@LayoutRes int layoutResId,
boolean clickable,
@LayoutRes int layoutId,
boolean disabled,
View.OnClickListener onClickListener,
int position) {
this.customView = customView;
this.layoutResId = layoutResId;
this.clickable = clickable;
this.layoutId = layoutId;
this.disabled = disabled;
this.onClickListener = onClickListener;
this.position = position;
}
@ -29,12 +29,12 @@ public class BaseBottomSheetItem {
}
@LayoutRes
public int getLayoutResId() {
return layoutResId;
public int getLayoutId() {
return layoutId;
}
public boolean isClickable() {
return clickable;
public boolean isDisabled() {
return disabled;
}
public View.OnClickListener getOnClickListener() {
@ -49,8 +49,8 @@ public class BaseBottomSheetItem {
protected View customView;
@LayoutRes
protected int layoutResId;
protected boolean clickable;
protected int layoutId;
protected boolean disabled;
protected View.OnClickListener onClickListener;
protected int position;
@ -59,13 +59,13 @@ public class BaseBottomSheetItem {
return this;
}
public Builder setLayoutResId(@LayoutRes int layoutResId) {
this.layoutResId = layoutResId;
public Builder setLayoutId(@LayoutRes int layoutId) {
this.layoutId = layoutId;
return this;
}
public Builder setClickable(boolean clickable) {
this.clickable = clickable;
public Builder setDisabled(boolean disabled) {
this.disabled = disabled;
return this;
}
@ -80,7 +80,7 @@ public class BaseBottomSheetItem {
}
public BaseBottomSheetItem create() {
return new BaseBottomSheetItem(customView, layoutResId, clickable, onClickListener, position);
return new BaseBottomSheetItem(customView, layoutId, disabled, onClickListener, position);
}
}
}

View file

@ -10,14 +10,14 @@ public class SimpleBottomSheetItem extends BaseBottomSheetItem {
private Drawable icon;
@DrawableRes
private int iconResId;
private int iconId;
@ColorRes
private int iconColorResId;
private int iconColorId;
private String title;
@StringRes
private int titleResId;
private int titleId;
@ColorRes
private int titleColorResId;
private int titleColorId;
public SimpleBottomSheetItem(View customView,
int layoutResId,
@ -25,65 +25,73 @@ public class SimpleBottomSheetItem extends BaseBottomSheetItem {
View.OnClickListener onClickListener,
int position,
Drawable icon,
int iconResId,
int iconColorResId,
@DrawableRes int iconId,
@ColorRes int iconColorId,
String title,
int titleResId,
int titleColorResId) {
@StringRes int titleId,
@ColorRes int titleColorId) {
super(customView, layoutResId, clickable, onClickListener, position);
this.icon = icon;
this.iconResId = iconResId;
this.iconColorResId = iconColorResId;
this.iconId = iconId;
this.iconColorId = iconColorId;
this.title = title;
this.titleResId = titleResId;
this.titleColorResId = titleColorResId;
this.titleId = titleId;
this.titleColorId = titleColorId;
}
public Drawable getIcon() {
return icon;
}
public int getIconResId() {
return iconResId;
@DrawableRes
public int getIconId() {
return iconId;
}
public int getIconColorResId() {
return iconColorResId;
@ColorRes
public int getIconColorId() {
return iconColorId;
}
public String getTitle() {
return title;
}
public int getTitleResId() {
return titleResId;
@StringRes
public int getTitleId() {
return titleId;
}
public int getTitleColorResId() {
return titleColorResId;
@ColorRes
public int getTitleColorId() {
return titleColorId;
}
public static class Builder extends BaseBottomSheetItem.Builder {
private Drawable icon;
private int iconResId;
private int iconColorResId;
private String title;
private int titleResId;
private int titleColorResId;
protected Drawable icon;
@DrawableRes
protected int iconId;
@ColorRes
protected int iconColorId;
protected String title;
@StringRes
protected int titleId;
@ColorRes
protected int titleColorId;
public Builder setIcon(Drawable icon) {
this.icon = icon;
return this;
}
public Builder setIconResId(int iconResId) {
this.iconResId = iconResId;
public Builder setIconId(@DrawableRes int iconId) {
this.iconId = iconId;
return this;
}
public Builder setIconColorResId(int iconColorResId) {
this.iconColorResId = iconColorResId;
public Builder setIconColorId(@ColorRes int iconColorId) {
this.iconColorId = iconColorId;
return this;
}
@ -92,28 +100,28 @@ public class SimpleBottomSheetItem extends BaseBottomSheetItem {
return this;
}
public Builder setTitleResId(int titleResId) {
this.titleResId = titleResId;
public Builder setTitleId(@StringRes int titleId) {
this.titleId = titleId;
return this;
}
public Builder setTitleColorResId(int titleColorResId) {
this.titleColorResId = titleColorResId;
public Builder setTitleColorId(@ColorRes int titleColorId) {
this.titleColorId = titleColorId;
return this;
}
public SimpleBottomSheetItem createSimpleBottomSheetItem() {
public SimpleBottomSheetItem create() {
return new SimpleBottomSheetItem(customView,
layoutResId,
clickable,
layoutId,
disabled,
onClickListener,
position,
icon,
iconResId,
iconColorResId,
iconId,
iconColorId,
title,
titleResId,
titleColorResId);
titleId,
titleColorId);
}
}
}