From e1e3f176679edc9df07dad7ea8951ccf5fbf84d2 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Fri, 10 Apr 2020 18:49:50 +0300 Subject: [PATCH 1/4] Add GPX waypoint action" Bottom Sheet --- OsmAnd/res/layout/gpx_track_select_dialog.xml | 19 --- OsmAnd/res/layout/gpx_track_select_item.xml | 5 +- .../osmand/plus/helpers/GpxTrackAdapter.java | 28 ++++- .../net/osmand/plus/helpers/GpxUiHelper.java | 70 +---------- .../helpers/SelectGpxTrackBottomSheet.java | 109 ++++++++++++++++++ .../editors/PointEditorFragmentNew.java | 1 + 6 files changed, 138 insertions(+), 94 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java diff --git a/OsmAnd/res/layout/gpx_track_select_dialog.xml b/OsmAnd/res/layout/gpx_track_select_dialog.xml index 88c1985298..3a2c2ab41d 100644 --- a/OsmAnd/res/layout/gpx_track_select_dialog.xml +++ b/OsmAnd/res/layout/gpx_track_select_dialog.xml @@ -47,23 +47,4 @@ tools:listitem="@layout/gpx_track_select_item"> - - - - - \ No newline at end of file diff --git a/OsmAnd/res/layout/gpx_track_select_item.xml b/OsmAnd/res/layout/gpx_track_select_item.xml index 844b1382f2..21e925e64b 100644 --- a/OsmAnd/res/layout/gpx_track_select_item.xml +++ b/OsmAnd/res/layout/gpx_track_select_item.xml @@ -2,7 +2,8 @@ @@ -21,7 +22,7 @@ gpxInfoList, boolean showCurrentGpx, - OnItemClickListener onItemClickListener) { + GpxTrackAdapter(Activity activity, List gpxInfoList, boolean showCurrentGpx) { this.showCurrentGpx = showCurrentGpx; - this.onItemClickListener = onItemClickListener; app = (OsmandApplication) activity.getApplication(); boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); themedInflater = UiUtilities.getInflater(activity, nightMode); @@ -123,8 +121,26 @@ public class GpxTrackAdapter extends RecyclerView.Adapter callbackWithObject) { + public static void selectSingleGPXFile(final MapActivity activity, boolean showCurrentGpx, + final CallbackWithObject callbackWithObject) { OsmandApplication app = (OsmandApplication) activity.getApplication(); int gpxDirLength = app.getAppPath(IndexConstants.GPX_INDEX_DIR).getAbsolutePath().length(); List selectedGpxFiles = app.getSelectedGpxHelper().getSelectedGPXFiles(); @@ -279,11 +277,8 @@ public class GpxUiHelper { list.add(new GPXInfo(gpxFile.path.substring(gpxDirLength + 1), gpxFile.modifiedTime, 0)); } } - - final ContextMenuAdapter adapter = createGpxContextMenuAdapter(list, null, showCurrentGpx); - return createSingleChoiceDialog(activity, showCurrentGpx, callbackWithObject, list, adapter); + SelectGpxTrackBottomSheet.showInstance(activity, showCurrentGpx, callbackWithObject, list); } - return null; } private static ContextMenuAdapter createGpxContextMenuAdapter(List allGpxList, @@ -350,65 +345,6 @@ public class GpxUiHelper { }, dir, null, filename); } - private static AlertDialog createSingleChoiceDialog(final Activity activity, - final boolean showCurrentGpx, - final CallbackWithObject callbackWithObject, - final List list, - final ContextMenuAdapter adapter) { - final OsmandApplication app = (OsmandApplication) activity.getApplication(); - boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); - final View customLayout = UiUtilities.getInflater(activity, nightMode).inflate(R.layout.gpx_track_select_dialog, null); - AlertDialog.Builder builder = new AlertDialog.Builder(UiUtilities.getThemedContext(activity, nightMode)); - builder.setView(customLayout); - final AlertDialog dlg = builder.create(); - View cancelButton = customLayout.findViewById(R.id.dismiss_button); - UiUtilities.setupDialogButton(nightMode, cancelButton, UiUtilities.DialogButtonType.SECONDARY, R.string.shared_string_cancel); - TextView gpxCounter = customLayout.findViewById(R.id.counter); - gpxCounter.setText(String.valueOf(adapter.length())); - GpxTrackAdapter gpxTrackAdapter = new GpxTrackAdapter(activity, list, showCurrentGpx, - new GpxTrackAdapter.OnItemClickListener() { - @Override - public void onItemClick(int position) { - if (position != -1 && position < list.size()) { - if (showCurrentGpx && position == 0) { - callbackWithObject.processResult(null); - app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(null); - } else { - String fileName = list.get(position).getFileName(); - app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(fileName); - SelectedGpxFile selectedGpxFile = - app.getSelectedGpxHelper().getSelectedFileByName(fileName); - if (selectedGpxFile != null) { - callbackWithObject.processResult(new GPXUtilities.GPXFile[]{selectedGpxFile.getGpxFile()}); - } else { - File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); - GpxUiHelper.loadGPXFileInDifferentThread(activity, callbackWithObject, dir, null, fileName); - } - } - } - dlg.dismiss(); - } - }); - RecyclerView recyclerView = customLayout.findViewById(R.id.gpx_track_list); - recyclerView.setAdapter(gpxTrackAdapter); - recyclerView.setLayoutManager(new LinearLayoutManager(app, LinearLayoutManager.VERTICAL, false)); - dlg.setCanceledOnTouchOutside(false); - dlg.show(); - cancelButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - dlg.dismiss(); - } - }); - try { - dlg.getListView().setFastScrollEnabled(true); - } catch (Exception e) { - // java.lang.ClassCastException: com.android.internal.widget.RoundCornerListAdapter - // Unknown reason but on some devices fail - } - return dlg; - } - private static class DialogGpxDataItemCallback implements GpxDataItemCallback { private static final int UPDATE_GPX_ITEM_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 6; private static final long MIN_UPDATE_INTERVAL = 500; diff --git a/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java b/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java new file mode 100644 index 0000000000..2864f41ffd --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java @@ -0,0 +1,109 @@ +package net.osmand.plus.helpers; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; + +import androidx.appcompat.view.ContextThemeWrapper; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import net.osmand.CallbackWithObject; +import net.osmand.GPXUtilities; +import net.osmand.IndexConstants; +import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; + +import java.io.File; +import java.util.List; + +public class SelectGpxTrackBottomSheet extends MenuBottomSheetDialogFragment { + + public static final String TAG = "SelectGpxTrackBottomSheet"; + + protected View mainView; + protected GpxTrackAdapter adapter; + + private List gpxInfoList; + private OsmandApplication app; + private boolean showCurrentGpx; + private CallbackWithObject callbackWithObject; + private Activity activity; + + private SelectGpxTrackBottomSheet(Activity activity, boolean showCurrentGpx, CallbackWithObject callbackWithObject, + List gpxInfoList) { + super(); + app = (OsmandApplication) activity.getApplication(); + this.activity = activity; + this.showCurrentGpx = showCurrentGpx; + this.gpxInfoList = gpxInfoList; + this.callbackWithObject = callbackWithObject; + } + + @Override + public void createMenuItems(Bundle savedInstanceState) { + final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), + R.layout.gpx_track_select_dialog, null); + + final RecyclerView recyclerView = mainView.findViewById(R.id.gpx_track_list); + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + adapter = createAdapter(); + adapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() { + @Override + public void onItemClick(int position) { + if (position != RecyclerView.NO_POSITION) { + SelectGpxTrackBottomSheet.this.onItemClick(position); + } + } + }); + recyclerView.setAdapter(adapter); + TextView gpxCounter = mainView.findViewById(R.id.counter); + gpxCounter.setText(String.valueOf(adapter.getItemCount())); + items.add(new BaseBottomSheetItem.Builder().setCustomView(mainView).create()); + } + + private GpxTrackAdapter createAdapter() { + return new GpxTrackAdapter(activity, gpxInfoList, showCurrentGpx); + } + + private void onItemClick(int position) { + if (position != -1 && position < gpxInfoList.size()) { + if (showCurrentGpx && position == 0) { + callbackWithObject.processResult(null); + app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(null); + } else { + String fileName = gpxInfoList.get(position).getFileName(); + app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(fileName); + GpxSelectionHelper.SelectedGpxFile selectedGpxFile = + app.getSelectedGpxHelper().getSelectedFileByName(fileName); + if (selectedGpxFile != null) { + callbackWithObject.processResult(new GPXUtilities.GPXFile[]{selectedGpxFile.getGpxFile()}); + } else { + File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); + GpxUiHelper.loadGPXFileInDifferentThread(activity, callbackWithObject, dir, null, fileName); + } + } + } + dismiss(); + } + + public static void showInstance(MapActivity mapActivity, boolean showCurrentGpx, + CallbackWithObject callbackWithObject, List gpxInfoList) { + SelectGpxTrackBottomSheet fragment = new SelectGpxTrackBottomSheet(mapActivity, showCurrentGpx, callbackWithObject, gpxInfoList); + fragment.setUsedOnMap(true); + fragment.setRetainInstance(true); + fragment.show(mapActivity.getSupportFragmentManager(), SelectGpxTrackBottomSheet.TAG); + } + + @Override + protected int getDismissButtonTextId() { + return R.string.shared_string_cancel; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index e096f6282b..21f21835d7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -625,6 +625,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { } public void dismiss(boolean includingMenu) { + hideKeyboard(); MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { if (includingMenu) { From c02c2e47e263e881af1a4d282d706dfb3720db5f Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 15 Apr 2020 18:32:08 +0300 Subject: [PATCH 2/4] Refactor --- .../osmand/plus/helpers/GpxTrackAdapter.java | 8 ++-- .../net/osmand/plus/helpers/GpxUiHelper.java | 5 ++- .../helpers/SelectGpxTrackBottomSheet.java | 43 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxTrackAdapter.java b/OsmAnd/src/net/osmand/plus/helpers/GpxTrackAdapter.java index cef242fca2..ab52559b28 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxTrackAdapter.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxTrackAdapter.java @@ -1,6 +1,6 @@ package net.osmand.plus.helpers; -import android.app.Activity; +import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,11 +36,11 @@ public class GpxTrackAdapter extends RecyclerView.Adapter gpxInfoList, boolean showCurrentGpx) { + GpxTrackAdapter(Context ctx, List gpxInfoList, boolean showCurrentGpx) { this.showCurrentGpx = showCurrentGpx; - app = (OsmandApplication) activity.getApplication(); + app = (OsmandApplication) ctx.getApplicationContext(); boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); - themedInflater = UiUtilities.getInflater(activity, nightMode); + themedInflater = UiUtilities.getInflater(ctx, nightMode); this.gpxInfoList = gpxInfoList; iconsCache = app.getUIUtilities(); } diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 84ab9c6071..6006d02c9a 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -37,6 +37,7 @@ import androidx.appcompat.widget.ListPopupWindow; import androidx.appcompat.widget.SwitchCompat; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; +import androidx.fragment.app.FragmentActivity; import com.github.mikephil.charting.charts.HorizontalBarChart; import com.github.mikephil.charting.charts.LineChart; @@ -257,7 +258,7 @@ public class GpxUiHelper { return null; } - public static void selectSingleGPXFile(final MapActivity activity, boolean showCurrentGpx, + public static void selectSingleGPXFile(final FragmentActivity activity, boolean showCurrentGpx, final CallbackWithObject callbackWithObject) { OsmandApplication app = (OsmandApplication) activity.getApplication(); int gpxDirLength = app.getAppPath(IndexConstants.GPX_INDEX_DIR).getAbsolutePath().length(); @@ -277,7 +278,7 @@ public class GpxUiHelper { list.add(new GPXInfo(gpxFile.path.substring(gpxDirLength + 1), gpxFile.modifiedTime, 0)); } } - SelectGpxTrackBottomSheet.showInstance(activity, showCurrentGpx, callbackWithObject, list); + SelectGpxTrackBottomSheet.showInstance(activity.getSupportFragmentManager(), showCurrentGpx, callbackWithObject, list); } } diff --git a/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java b/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java index 2864f41ffd..e56efac33e 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java @@ -1,11 +1,11 @@ package net.osmand.plus.helpers; -import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.TextView; import androidx.appcompat.view.ContextThemeWrapper; +import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -15,7 +15,6 @@ import net.osmand.IndexConstants; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; @@ -24,24 +23,23 @@ import java.util.List; public class SelectGpxTrackBottomSheet extends MenuBottomSheetDialogFragment { - public static final String TAG = "SelectGpxTrackBottomSheet"; + public static final String TAG = SelectGpxTrackBottomSheet.class.getSimpleName(); protected View mainView; protected GpxTrackAdapter adapter; - private List gpxInfoList; - private OsmandApplication app; private boolean showCurrentGpx; private CallbackWithObject callbackWithObject; - private Activity activity; - private SelectGpxTrackBottomSheet(Activity activity, boolean showCurrentGpx, CallbackWithObject callbackWithObject, - List gpxInfoList) { - super(); - app = (OsmandApplication) activity.getApplication(); - this.activity = activity; - this.showCurrentGpx = showCurrentGpx; + private void setGpxInfoList(List gpxInfoList) { this.gpxInfoList = gpxInfoList; + } + + private void setShowCurrentGpx(boolean showCurrentGpx) { + this.showCurrentGpx = showCurrentGpx; + } + + private void setCallbackWithObject(CallbackWithObject callbackWithObject) { this.callbackWithObject = callbackWithObject; } @@ -53,7 +51,7 @@ public class SelectGpxTrackBottomSheet extends MenuBottomSheetDialogFragment { final RecyclerView recyclerView = mainView.findViewById(R.id.gpx_track_list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - adapter = createAdapter(); + adapter = new GpxTrackAdapter(requireContext(), gpxInfoList, showCurrentGpx); adapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() { @Override public void onItemClick(int position) { @@ -68,12 +66,9 @@ public class SelectGpxTrackBottomSheet extends MenuBottomSheetDialogFragment { items.add(new BaseBottomSheetItem.Builder().setCustomView(mainView).create()); } - private GpxTrackAdapter createAdapter() { - return new GpxTrackAdapter(activity, gpxInfoList, showCurrentGpx); - } - private void onItemClick(int position) { if (position != -1 && position < gpxInfoList.size()) { + OsmandApplication app = (OsmandApplication) requireActivity().getApplication(); if (showCurrentGpx && position == 0) { callbackWithObject.processResult(null); app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(null); @@ -86,24 +81,28 @@ public class SelectGpxTrackBottomSheet extends MenuBottomSheetDialogFragment { callbackWithObject.processResult(new GPXUtilities.GPXFile[]{selectedGpxFile.getGpxFile()}); } else { File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); - GpxUiHelper.loadGPXFileInDifferentThread(activity, callbackWithObject, dir, null, fileName); + GpxUiHelper.loadGPXFileInDifferentThread(requireActivity(), callbackWithObject, dir, null, fileName); } } } dismiss(); } - public static void showInstance(MapActivity mapActivity, boolean showCurrentGpx, + public static void showInstance(FragmentManager fragmentManager, boolean showCurrentGpx, CallbackWithObject callbackWithObject, List gpxInfoList) { - SelectGpxTrackBottomSheet fragment = new SelectGpxTrackBottomSheet(mapActivity, showCurrentGpx, callbackWithObject, gpxInfoList); + SelectGpxTrackBottomSheet fragment = new SelectGpxTrackBottomSheet(); fragment.setUsedOnMap(true); fragment.setRetainInstance(true); - fragment.show(mapActivity.getSupportFragmentManager(), SelectGpxTrackBottomSheet.TAG); + fragment.setShowCurrentGpx(showCurrentGpx); + fragment.setCallbackWithObject(callbackWithObject); + fragment.setGpxInfoList(gpxInfoList); + if (!fragmentManager.isStateSaved()) { + fragment.show(fragmentManager, SelectGpxTrackBottomSheet.TAG); + } } @Override protected int getDismissButtonTextId() { return R.string.shared_string_cancel; } - } From d09e7346dcf96bccaafe3765aecb9b1baee319d1 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 15 Apr 2020 18:51:35 +0300 Subject: [PATCH 3/4] Refactor --- OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 33654ce4e8..a44e460a27 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -37,8 +37,6 @@ import androidx.appcompat.widget.ListPopupWindow; import androidx.appcompat.widget.SwitchCompat; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; import androidx.fragment.app.FragmentActivity; import com.github.mikephil.charting.charts.HorizontalBarChart; From a963f82c1d28b75c8e4c39c15755cf3f2079e7b1 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 15 Apr 2020 19:07:31 +0300 Subject: [PATCH 4/4] Refactor --- OsmAnd/assets/poi_categories.json | 14 -------------- .../helpers/SelectGpxTrackBottomSheet.java | 18 +++++++++++------- 2 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 OsmAnd/assets/poi_categories.json diff --git a/OsmAnd/assets/poi_categories.json b/OsmAnd/assets/poi_categories.json deleted file mode 100644 index 51afd627af..0000000000 --- a/OsmAnd/assets/poi_categories.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "categories" : { - "special" : { - "icons" : [ - "special_star", "special_star_stroked", "special_marker", "special_flag_stroke", "special_house", "special_building" - ] - }, - "amenity" : { - "icons": [ - "amenity_bar", "amenity_cafe", "amenity_atm", "amenity_biergarten", "amenity_cinema", "amenity_fire_station", "amenity_parking" - ] - } - } -} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java b/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java index e56efac33e..be1dfcd63d 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/helpers/SelectGpxTrackBottomSheet.java @@ -1,5 +1,6 @@ package net.osmand.plus.helpers; +import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.TextView; @@ -81,7 +82,10 @@ public class SelectGpxTrackBottomSheet extends MenuBottomSheetDialogFragment { callbackWithObject.processResult(new GPXUtilities.GPXFile[]{selectedGpxFile.getGpxFile()}); } else { File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); - GpxUiHelper.loadGPXFileInDifferentThread(requireActivity(), callbackWithObject, dir, null, fileName); + Activity activity = getActivity(); + if (activity != null) { + GpxUiHelper.loadGPXFileInDifferentThread(activity, callbackWithObject, dir, null, fileName); + } } } } @@ -90,13 +94,13 @@ public class SelectGpxTrackBottomSheet extends MenuBottomSheetDialogFragment { public static void showInstance(FragmentManager fragmentManager, boolean showCurrentGpx, CallbackWithObject callbackWithObject, List gpxInfoList) { - SelectGpxTrackBottomSheet fragment = new SelectGpxTrackBottomSheet(); - fragment.setUsedOnMap(true); - fragment.setRetainInstance(true); - fragment.setShowCurrentGpx(showCurrentGpx); - fragment.setCallbackWithObject(callbackWithObject); - fragment.setGpxInfoList(gpxInfoList); if (!fragmentManager.isStateSaved()) { + SelectGpxTrackBottomSheet fragment = new SelectGpxTrackBottomSheet(); + fragment.setUsedOnMap(true); + fragment.setRetainInstance(true); + fragment.setShowCurrentGpx(showCurrentGpx); + fragment.setCallbackWithObject(callbackWithObject); + fragment.setGpxInfoList(gpxInfoList); fragment.show(fragmentManager, SelectGpxTrackBottomSheet.TAG); } }