From c93632e874e8912f2797fd85dbc822063995613f Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 7 Sep 2017 18:36:37 +0300 Subject: [PATCH] Fix issue with fragments --- .../mapmarkers/MapMarkersDialogFragment.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 87cb0ad019..abd1ade119 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -43,8 +43,20 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { - activeFragment = new MapMarkersActiveFragment(); - historyFragment = new MapMarkersHistoryFragment(); + List fragments = getChildFragmentManager().getFragments(); + for (Fragment fragment : fragments) { + if (fragment instanceof MapMarkersActiveFragment) { + activeFragment = (MapMarkersActiveFragment) fragment; + } else if (fragment instanceof MapMarkersHistoryFragment) { + historyFragment = (MapMarkersHistoryFragment) fragment; + } + } + if (activeFragment == null) { + activeFragment = new MapMarkersActiveFragment(); + } + if (historyFragment == null) { + historyFragment = new MapMarkersHistoryFragment(); + } FragmentManager fragmentManager = getChildFragmentManager(); Fragment markerOptionsFragment = fragmentManager.findFragmentByTag(MarkerOptionsBottomSheetDialogFragment.TAG);