Rewrite UI in AddGroupBottomSheetDialogFragment

This commit is contained in:
Alexander Sytnyk 2018-02-27 18:50:06 +02:00
parent 3c1f14b1fe
commit fa4a8ef876
5 changed files with 37 additions and 41 deletions

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/close_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/close_row_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_cancel"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>

View file

@ -27,6 +27,23 @@
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<include layout="@layout/bottom_sheet_item_cancel"/>
<FrameLayout
android:id="@+id/close_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/close_row_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_cancel"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -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"/>
<ProgressBar
android:id="@+id/progress_bar"
@ -36,11 +35,4 @@
osmand:typeface="@string/font_roboto_medium"
tools:visibility="visible"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<include layout="@layout/bottom_sheet_item_cancel"/>
</LinearLayout>

View file

@ -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);

View file

@ -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