From 3a7d6a9626f37b59af013ccceb049a8027dfd91f Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 15 Mar 2018 12:15:53 +0200 Subject: [PATCH] Add methods for setup the right bottom button in MenuBottomSheetDialogFragment --- .../base/MenuBottomSheetDialogFragment.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index 327eaadf24..a80d28f5a7 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -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;