Fix split card visibility

This commit is contained in:
Vitaliy 2020-07-31 12:02:16 +03:00
parent 0f89e927e0
commit 30a7ebcb30
2 changed files with 16 additions and 10 deletions

View file

@ -15,7 +15,6 @@ import com.google.android.material.slider.Slider;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -30,6 +29,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -310,17 +310,11 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment {
@NonNull @NonNull
public List<GpxDisplayGroup> getDisplayGroups() { public List<GpxDisplayGroup> getDisplayGroups() {
List<GpxDisplayGroup> groups = new ArrayList<>();
Fragment target = getTargetFragment(); Fragment target = getTargetFragment();
if (target instanceof TrackAppearanceFragment) { if (target instanceof TrackAppearanceFragment) {
List<GpxDisplayGroup> result = ((TrackAppearanceFragment) target).getGpxDisplayGroups(); return ((TrackAppearanceFragment) target).getDisplaySegmentGroups();
for (GpxDisplayGroup group : result) {
if (GpxDisplayItemType.TRACK_SEGMENT == group.getType()) {
groups.add(group);
}
}
} }
return groups; return Collections.emptyList();
} }
public static void showInstance(@NonNull FragmentManager fragmentManager, TrackDrawInfo trackDrawInfo, Fragment target) { public static void showInstance(@NonNull FragmentManager fragmentManager, TrackDrawInfo trackDrawInfo, Fragment target) {

View file

@ -28,6 +28,7 @@ import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -544,7 +545,7 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
ViewGroup cardsContainer = getCardsContainer(); ViewGroup cardsContainer = getCardsContainer();
cardsContainer.removeAllViews(); cardsContainer.removeAllViews();
if (!selectedGpxFile.isShowCurrentTrack()) { if (!selectedGpxFile.isShowCurrentTrack() && !Algorithms.isEmpty(getDisplaySegmentGroups())) {
splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo); splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo);
splitIntervalCard.setListener(this); splitIntervalCard.setListener(this);
cardsContainer.addView(splitIntervalCard.build(mapActivity)); cardsContainer.addView(splitIntervalCard.build(mapActivity));
@ -579,6 +580,17 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
return displayGroups; return displayGroups;
} }
@NonNull
public List<GpxDisplayGroup> getDisplaySegmentGroups() {
List<GpxDisplayGroup> groups = new ArrayList<>();
for (GpxDisplayGroup group : getGpxDisplayGroups()) {
if (GpxDisplayItemType.TRACK_SEGMENT == group.getType()) {
groups.add(group);
}
}
return groups;
}
public void dismissImmediate() { public void dismissImmediate() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {