Selected categories

This commit is contained in:
androiddevkotlin 2021-03-01 16:58:22 +02:00
parent 4c04c7ee19
commit c78a934d8f
3 changed files with 19 additions and 6 deletions

View file

@ -141,7 +141,7 @@ public abstract class PointEditorFragment extends BaseOsmAndFragment {
FragmentManager fragmentManager = getFragmentManager();
SelectFavoriteCategoryBottomSheet dialogFragment = createSelectCategoryDialog();
if (fragmentManager != null && dialogFragment != null) {
dialogFragment.showInstance(getChildFragmentManager(), getTargetFragment());
dialogFragment.show(fragmentManager, SelectFavoriteCategoryBottomSheet.class.getSimpleName());
}
return true;
}

View file

@ -195,7 +195,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
FragmentManager fragmentManager = getFragmentManager();
SelectFavoriteCategoryBottomSheet dialogFragment = createSelectCategoryDialog();
if (fragmentManager != null && dialogFragment != null) {
dialogFragment.showInstance(getChildFragmentManager(), getTargetFragment());
dialogFragment.show(fragmentManager, SelectFavoriteCategoryBottomSheet.class.getSimpleName());
}
}
});
@ -741,6 +741,17 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
}
}
@Nullable
protected AddNewFavoriteCategoryBottomSheet createAddCategoryDialog() {
PointEditor editor = getEditor();
if (editor != null) {
return AddNewFavoriteCategoryBottomSheet.createInstance(editor.getFragmentTag(), getCategories(),
!editor.getFragmentTag().equals(FavoritePointEditor.TAG));
} else {
return null;
}
}
@Override
public void onDestroyView() {
PointEditor editor = getEditor();
@ -1008,8 +1019,9 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen
@Override
public void onClick(View view) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager != null) {
SelectFavoriteCategoryBottomSheet.showInstance(getChildFragmentManager(), getTargetFragment());
AddNewFavoriteCategoryBottomSheet dialogFragment = createAddCategoryDialog();
if (fragmentManager != null && dialogFragment != null) {
dialogFragment.show(fragmentManager, SelectFavoriteCategoryBottomSheet.class.getSimpleName());
}
}
});

View file

@ -32,6 +32,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.myplaces.AddNewTrackFolderBottomSheet;
import java.util.List;
import java.util.Map;
@ -43,7 +44,7 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
private static final String KEY_CTX_SEL_CAT_EDITOR_TAG = "key_ctx_sel_cat_editor_tag";
private OsmandApplication app;
private GPXUtilities.GPXFile gpxFile;
private String editorTag;
private static String editorTag;
private Map<String, Integer> gpxCategories;
private SelectFavoriteCategoryBottomSheet.CategorySelectionListener selectionListener;
@ -125,7 +126,7 @@ public class SelectFavoriteCategoryBottomSheet extends MenuBottomSheetDialogFrag
MapActivity mapActivity = (MapActivity) activity;
Set<String> categories = gpxCategories != null ? gpxCategories.keySet() : null;
AddNewFavoriteCategoryBottomSheet fragment = AddNewFavoriteCategoryBottomSheet.createInstance(editorTag, categories, gpxFile != null);
AddNewFavoriteCategoryBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), getTargetFragment());
fragment.show(mapActivity.getSupportFragmentManager(), AddNewTrackFolderBottomSheet.class.getName());
fragment.setSelectionListener(selectionListener);
dismiss();
}