Fix gpx markers issues for single category

This commit is contained in:
Chumva 2018-11-13 14:56:27 +02:00
parent 5bf7208791
commit 82684ff41e
2 changed files with 18 additions and 24 deletions

View file

@ -645,7 +645,7 @@ public class MapMarkersHelper {
Iterator<MapMarker> iterator = groupMarkers.iterator();
while (iterator.hasNext()) {
MapMarker marker = iterator.next();
if (marker.id.equals(group.getId() + name + MapUtils.createShortLinkString(marker.point.getLatitude(), marker.point.getLongitude(), 15))) {
if (marker.id.equals(group.getId() + name + MapUtils.createShortLinkString(latLon.getLatitude(), latLon.getLongitude(), 15))) {
exists = true;
marker.favouritePoint = favouritePoint;
marker.wptPt = wptPt;

View file

@ -446,7 +446,19 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
final GPXFile[] gpxFile = new GPXFile[1];
boolean disabled = !enabled;
if (groupIsDisabled && !group.wasShown() && !group.getWptCategories().isEmpty()) {
mapMarkersHelper.updateGroupDisabled(group, disabled);
if (group.getType() == MapMarkersGroup.GPX_TYPE) {
group.setVisibleUntilRestart(disabled);
String gpxPath = group.getGpxPath();
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxPath);
if (selectedGpxFile != null) {
gpxFile[0] = selectedGpxFile.getGpxFile();
} else {
// TODO IO load in another thread ?
gpxFile[0] = GPXUtilities.loadGPXFile(app, new File(gpxPath));
}
switchGpxVisibility(gpxFile[0], selectedGpxFile, !disabled);
if (enabled && !group.wasShown() && gpxFile[0] != null && gpxFile[0].getWaypointCategories(false).size() > 1) {
group.setWasShown(true);
Bundle args = new Bundle();
args.putString(SelectWptCategoriesBottomSheetDialogFragment.GPX_FILE_PATH_KEY, group.getGpxPath());
@ -458,23 +470,6 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
fragment.setUsedOnMap(false);
fragment.show(mapActivity.getSupportFragmentManager(), SelectWptCategoriesBottomSheetDialogFragment.TAG);
}
mapMarkersHelper.updateGroupDisabled(group, disabled);
if (group.getType() == MapMarkersGroup.GPX_TYPE) {
group.setVisibleUntilRestart(disabled);
String gpxPath = group.getGpxPath();
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxPath);
if (disabled) {
if (selectedGpxFile != null) {
gpxFile[0] = selectedGpxFile.getGpxFile();
switchGpxVisibility(gpxFile[0], selectedGpxFile, false);
}
} else {
if (selectedGpxFile == null) {
// TODO IO load in another thread ?
gpxFile[0] = GPXUtilities.loadGPXFile(app, new File(gpxPath));
switchGpxVisibility(gpxFile[0], null, true);
}
}
}
if(!disabled) {
mapMarkersHelper.enableGroup(group);
@ -482,7 +477,6 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
mapMarkersHelper.runSynchronization(group);
}
if (disabled) {
snackbar = Snackbar.make(holder.itemView, app.getString(R.string.group_will_be_removed_after_restart), Snackbar.LENGTH_LONG)
.setAction(R.string.shared_string_undo, new View.OnClickListener() {