From fa4a8ef87629d2751742000354b24727639be349 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 27 Feb 2018 18:50:06 +0200 Subject: [PATCH] Rewrite UI in AddGroupBottomSheetDialogFragment --- .../res/layout/bottom_sheet_item_cancel.xml | 19 ------------------- OsmAnd/res/layout/bottom_sheet_menu_base.xml | 19 ++++++++++++++++++- ...t_marker_add_group_bottom_sheet_dialog.xml | 10 +--------- .../base/MenuBottomSheetDialogFragment.java | 15 +++++++++++++-- .../AddGroupBottomSheetDialogFragment.java | 15 +++++---------- 5 files changed, 37 insertions(+), 41 deletions(-) delete mode 100644 OsmAnd/res/layout/bottom_sheet_item_cancel.xml diff --git a/OsmAnd/res/layout/bottom_sheet_item_cancel.xml b/OsmAnd/res/layout/bottom_sheet_item_cancel.xml deleted file mode 100644 index ede9b7246f..0000000000 --- a/OsmAnd/res/layout/bottom_sheet_item_cancel.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - diff --git a/OsmAnd/res/layout/bottom_sheet_menu_base.xml b/OsmAnd/res/layout/bottom_sheet_menu_base.xml index ce1ee74322..0cd6c6fc04 100644 --- a/OsmAnd/res/layout/bottom_sheet_menu_base.xml +++ b/OsmAnd/res/layout/bottom_sheet_menu_base.xml @@ -27,6 +27,23 @@ android:layout_height="1dp" android:background="?attr/dashboard_divider"/> - + + + + + diff --git a/OsmAnd/res/layout/fragment_marker_add_group_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_add_group_bottom_sheet_dialog.xml index f3d754416f..8d5b5f0bef 100644 --- a/OsmAnd/res/layout/fragment_marker_add_group_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_marker_add_group_bottom_sheet_dialog.xml @@ -11,8 +11,7 @@ android:id="@+id/groups_recycler_view" android:layout_width="match_parent" android:layout_height="wrap_content" - android:clipToPadding="false" - android:paddingBottom="@dimen/bottom_sheet_content_padding_small"/> + android:clipToPadding="false"/> - - - - \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index dbebf0aa59..b0a9ebfe6b 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -37,6 +37,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra protected boolean usedOnMap = true; protected boolean nightMode; + private LinearLayout itemsContainer; + public void setUsedOnMap(boolean usedOnMap) { this.usedOnMap = usedOnMap; } @@ -62,10 +64,10 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; View mainView = View.inflate(new ContextThemeWrapper(app, themeRes), R.layout.bottom_sheet_menu_base, null); - LinearLayout container = (LinearLayout) mainView.findViewById(R.id.items_container); + itemsContainer = (LinearLayout) mainView.findViewById(R.id.items_container); for (BaseBottomSheetItem item : items) { - item.inflate(app, container, nightMode); + item.inflate(app, itemsContainer, nightMode); } int closeRowDividerColorId = getCloseRowDividerColorId(); @@ -106,6 +108,15 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra outState.putBoolean(USED_ON_MAP_KEY, usedOnMap); } + @Override + public void onDestroyView() { + super.onDestroyView(); + items.clear(); + if (itemsContainer != null) { + itemsContainer.removeAllViews(); + } + } + // inflater, parent and return value are temporary and will be deleted public abstract View createMenuItems(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java index 73a0762911..47fe043663 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java @@ -13,6 +13,7 @@ import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.mapmarkers.adapters.GroupsAdapter; public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { @@ -37,7 +38,8 @@ public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetD @Override public View createMenuItems(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; - mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_add_group_bottom_sheet_dialog, container); + mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), + R.layout.fragment_marker_add_group_bottom_sheet_dialog, null); final RecyclerView recyclerView = mainView.findViewById(R.id.groups_recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); @@ -65,16 +67,9 @@ public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetD }); recyclerView.setAdapter(adapter); - mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - dismiss(); - } - }); + items.add(new BaseBottomSheetItem.Builder().setCustomView(mainView).create()); - setupHeightAndBackground(mainView, R.id.groups_recycler_view); - - return mainView; + return null; } @Override