diff --git a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java index e102dfffa9..15d94db2cc 100644 --- a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java @@ -15,7 +15,6 @@ import com.google.android.material.slider.Slider; import net.osmand.PlatformUtil; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; -import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; @@ -30,6 +29,7 @@ import net.osmand.plus.helpers.AndroidUiHelper; import org.apache.commons.logging.Log; import java.util.ArrayList; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -310,17 +310,11 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { @NonNull public List getDisplayGroups() { - List groups = new ArrayList<>(); Fragment target = getTargetFragment(); if (target instanceof TrackAppearanceFragment) { - List result = ((TrackAppearanceFragment) target).getGpxDisplayGroups(); - for (GpxDisplayGroup group : result) { - if (GpxDisplayItemType.TRACK_SEGMENT == group.getType()) { - groups.add(group); - } - } + return ((TrackAppearanceFragment) target).getDisplaySegmentGroups(); } - return groups; + return Collections.emptyList(); } public static void showInstance(@NonNull FragmentManager fragmentManager, TrackDrawInfo trackDrawInfo, Fragment target) { diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index c56311e932..0c2176687c 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -28,6 +28,7 @@ import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; +import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -544,7 +545,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement ViewGroup cardsContainer = getCardsContainer(); cardsContainer.removeAllViews(); - if (!selectedGpxFile.isShowCurrentTrack()) { + if (!selectedGpxFile.isShowCurrentTrack() && !Algorithms.isEmpty(getDisplaySegmentGroups())) { splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo); splitIntervalCard.setListener(this); cardsContainer.addView(splitIntervalCard.build(mapActivity)); @@ -579,6 +580,17 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement return displayGroups; } + @NonNull + public List getDisplaySegmentGroups() { + List groups = new ArrayList<>(); + for (GpxDisplayGroup group : getGpxDisplayGroups()) { + if (GpxDisplayItemType.TRACK_SEGMENT == group.getType()) { + groups.add(group); + } + } + return groups; + } + public void dismissImmediate() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) {