Refactor creation of markers sync groups
This commit is contained in:
parent
cfaf04e3b2
commit
0df3d3afa5
4 changed files with 8 additions and 13 deletions
|
@ -10,14 +10,13 @@ import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -180,8 +179,7 @@ public class WptPtEditorFragment extends PointEditorFragment {
|
||||||
private void syncGpx(GPXFile gpxFile) {
|
private void syncGpx(GPXFile gpxFile) {
|
||||||
File gpx = new File(gpxFile.path);
|
File gpx = new File(gpxFile.path);
|
||||||
if (gpx.exists()) {
|
if (gpx.exists()) {
|
||||||
getMyApplication().getMapMarkersHelper().syncGroupAsync(new MarkersSyncGroup(gpx.getAbsolutePath(),
|
getMyApplication().getMapMarkersHelper().syncGroupAsync(MapMarkersHelper.createGroup(gpx));
|
||||||
AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import android.os.Bundle;
|
||||||
|
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
import net.osmand.plus.mapmarkers.adapters.FavouritesGroupsAdapter;
|
import net.osmand.plus.mapmarkers.adapters.FavouritesGroupsAdapter;
|
||||||
import net.osmand.plus.mapmarkers.adapters.GroupsAdapter;
|
import net.osmand.plus.mapmarkers.adapters.GroupsAdapter;
|
||||||
|
|
||||||
|
@ -30,6 +30,6 @@ public class AddFavouritesGroupBottomSheetDialogFragment extends AddGroupBottomS
|
||||||
if (!group.visible) {
|
if (!group.visible) {
|
||||||
favouritesDbHelper.editFavouriteGroup(group, group.name, group.color, true);
|
favouritesDbHelper.editFavouriteGroup(group, group.name, group.color, true);
|
||||||
}
|
}
|
||||||
addAndSyncGroup(new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE));
|
addAndSyncGroup(MapMarkersHelper.createGroup(group));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.plus.GPXDatabase;
|
import net.osmand.plus.GPXDatabase;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
|
@ -18,6 +17,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -84,7 +84,7 @@ public class AddTracksGroupBottomSheetDialogFragment extends AddGroupBottomSheet
|
||||||
GPXFile res = GPXUtilities.loadGPXFile(app, gpx);
|
GPXFile res = GPXUtilities.loadGPXFile(app, gpx);
|
||||||
gpxSelectionHelper.selectGpxFile(res, true, false, false);
|
gpxSelectionHelper.selectGpxFile(res, true, false, false);
|
||||||
}
|
}
|
||||||
return new MarkersSyncGroup(gpx.getAbsolutePath(), AndroidUtils.trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE);
|
return MapMarkersHelper.createGroup(gpx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.view.View;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
|
@ -121,10 +120,8 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
|
||||||
gpxSelectionHelper.selectGpxFile(gpxFile, true, false, false);
|
gpxSelectionHelper.selectGpxFile(gpxFile, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkersSyncGroup syncGroup = new MarkersSyncGroup(gpxFile.path,
|
MarkersSyncGroup syncGroup = MapMarkersHelper.createGroup(new File(gpxFile.path));
|
||||||
AndroidUtils.trimExtension(new File(gpxFile.path).getName()),
|
syncGroup.setWptCategories(selectedCategories);
|
||||||
MarkersSyncGroup.GPX_TYPE,
|
|
||||||
selectedCategories);
|
|
||||||
|
|
||||||
mapMarkersHelper.addMarkersSyncGroup(syncGroup);
|
mapMarkersHelper.addMarkersSyncGroup(syncGroup);
|
||||||
mapMarkersHelper.syncGroupAsync(syncGroup, new MapMarkersHelper.OnGroupSyncedListener() {
|
mapMarkersHelper.syncGroupAsync(syncGroup, new MapMarkersHelper.OnGroupSyncedListener() {
|
||||||
|
|
Loading…
Reference in a new issue