Add methods for setup the right bottom button in MenuBottomSheetDialogFragment

This commit is contained in:
Alexander Sytnyk 2018-03-15 12:15:53 +02:00
parent fd43a3c59e
commit 3a7d6a9626

View file

@ -78,6 +78,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
if (bottomDividerColorId != -1) {
mainView.findViewById(R.id.bottom_row_divider).setBackgroundColor(getResolvedColor(bottomDividerColorId));
}
mainView.findViewById(R.id.dismiss_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -87,6 +88,24 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
});
((TextView) mainView.findViewById(R.id.dismiss_button_text)).setText(getDismissButtonTextId());
int rightBottomButtonTextId = getRightBottomButtonTextId();
if (rightBottomButtonTextId != -1) {
View buttonsDivider = mainView.findViewById(R.id.bottom_buttons_divider);
buttonsDivider.setVisibility(View.VISIBLE);
if (bottomDividerColorId != -1) {
buttonsDivider.setBackgroundColor(getResolvedColor(bottomDividerColorId));
}
View rightButton = mainView.findViewById(R.id.right_bottom_button);
rightButton.setVisibility(View.VISIBLE);
rightButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onRightBottomButtonClick();
}
});
((TextView) rightButton.findViewById(R.id.right_bottom_button_text)).setText(rightBottomButtonTextId);
}
setupHeightAndBackground(mainView);
return mainView;
@ -188,6 +207,15 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
}
@StringRes
protected int getRightBottomButtonTextId() {
return -1;
}
protected void onRightBottomButtonClick() {
}
@ColorRes
protected int getBgColorId() {
return nightMode ? R.color.bg_color_dark : R.color.bg_color_light;