Fix syncAllGroups method; rename items in MapMarkersOrderByMode enum
This commit is contained in:
parent
a5f53bfcb1
commit
48b123096b
4 changed files with 21 additions and 29 deletions
|
@ -501,7 +501,6 @@ public class AppInitializer implements IProgress {
|
|||
startBgTime = System.currentTimeMillis();
|
||||
app.favorites.loadFavorites();
|
||||
notifyEvent(InitEvents.FAVORITES_INITIALIZED);
|
||||
app.mapMarkersHelper.syncAllGroups(true);
|
||||
// init poi types before indexes and before POI
|
||||
initPoiTypes();
|
||||
notifyEvent(InitEvents.POI_TYPES_INITIALIZED);
|
||||
|
@ -522,6 +521,7 @@ public class AppInitializer implements IProgress {
|
|||
notifyEvent(InitEvents.LOAD_GPX_TRACKS);
|
||||
saveGPXTracks();
|
||||
notifyEvent(InitEvents.SAVE_GPX_TRACKS);
|
||||
app.mapMarkersHelper.syncAllGroups();
|
||||
// restore backuped favorites to normal file
|
||||
restoreBackupForFavoritesFiles();
|
||||
notifyEvent(InitEvents.RESTORE_BACKUPS);
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.data.LocationPoint;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
@ -320,18 +321,14 @@ public class MapMarkersHelper {
|
|||
return markersDbHelper.getGroup(id) != null;
|
||||
}
|
||||
|
||||
public void syncAllGroups(boolean startupSync) {
|
||||
public void syncAllGroups() {
|
||||
List<MarkersSyncGroup> groups = markersDbHelper.getAllGroups();
|
||||
for (MarkersSyncGroup gr : groups) {
|
||||
syncGroup(gr, startupSync);
|
||||
syncGroup(gr);
|
||||
}
|
||||
}
|
||||
|
||||
public void syncGroup(MarkersSyncGroup group) {
|
||||
syncGroup(group, false);
|
||||
}
|
||||
|
||||
private void syncGroup(MarkersSyncGroup group, boolean startupSync) {
|
||||
if (!isGroupSynced(group.getId())) {
|
||||
return;
|
||||
}
|
||||
|
@ -359,13 +356,8 @@ public class MapMarkersHelper {
|
|||
return;
|
||||
}
|
||||
|
||||
GPXFile gpx;
|
||||
if (startupSync) {
|
||||
gpx = GPXUtilities.loadGPXFile(ctx, file);
|
||||
gpxHelper.selectGpxFile(gpx, true, false);
|
||||
} else {
|
||||
gpx = gpxHelper.getSelectedFileByPath(group.getId()).getGpxFile();
|
||||
}
|
||||
SelectedGpxFile selectedGpxFile = gpxHelper.getSelectedFileByPath(group.getId());
|
||||
GPXFile gpx = selectedGpxFile == null ? null : selectedGpxFile.getGpxFile();
|
||||
if (gpx == null) {
|
||||
removeActiveMarkersFromSyncGroup(group.getId());
|
||||
return;
|
||||
|
|
|
@ -1321,7 +1321,7 @@ public class OsmandSettings {
|
|||
new EnumIntPreference<>("map_markers_mode", MapMarkersMode.TOOLBAR, MapMarkersMode.values());
|
||||
|
||||
public final CommonPreference<MapMarkersOrderByMode> MAP_MARKERS_ORDER_BY_MODE =
|
||||
new EnumIntPreference<>("map_markers_order_by_mode", MapMarkersOrderByMode.DATE_ADDED_DESCENDINGLY, MapMarkersOrderByMode.values());
|
||||
new EnumIntPreference<>("map_markers_order_by_mode", MapMarkersOrderByMode.DATE_ADDED_DESC, MapMarkersOrderByMode.values());
|
||||
|
||||
{
|
||||
MAP_MARKERS_MODE.makeProfile().cache();
|
||||
|
@ -3155,18 +3155,18 @@ public class OsmandSettings {
|
|||
}
|
||||
|
||||
public enum MapMarkersOrderByMode {
|
||||
DISTANCE_DESCENDINGLY,
|
||||
DISTANCE_ASCENDINGLY,
|
||||
DISTANCE_DESC,
|
||||
DISTANCE_ASC,
|
||||
NAME,
|
||||
DATE_ADDED_DESCENDINGLY,
|
||||
DATE_ADDED_ASCENDINGLY;
|
||||
DATE_ADDED_DESC,
|
||||
DATE_ADDED_ASC;
|
||||
|
||||
public boolean isDistanceDescending() {
|
||||
return this == DISTANCE_DESCENDINGLY;
|
||||
return this == DISTANCE_DESC;
|
||||
}
|
||||
|
||||
public boolean isDistanceAscending() {
|
||||
return this == DISTANCE_ASCENDINGLY;
|
||||
return this == DISTANCE_ASC;
|
||||
}
|
||||
|
||||
public boolean isName() {
|
||||
|
@ -3174,11 +3174,11 @@ public class OsmandSettings {
|
|||
}
|
||||
|
||||
public boolean isDateAddedDescending() {
|
||||
return this == DATE_ADDED_DESCENDINGLY;
|
||||
return this == DATE_ADDED_DESC;
|
||||
}
|
||||
|
||||
public boolean isDateAddedAscending() {
|
||||
return this == DATE_ADDED_ASCENDINGLY;
|
||||
return this == DATE_ADDED_ASC;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,20 +129,20 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
MapMarkersOrderByMode modeToSet;
|
||||
switch (view.getId()) {
|
||||
case R.id.distance_row:
|
||||
if (currentOrderByMode == MapMarkersOrderByMode.DISTANCE_DESCENDINGLY) {
|
||||
modeToSet = MapMarkersOrderByMode.DISTANCE_ASCENDINGLY;
|
||||
if (currentOrderByMode == MapMarkersOrderByMode.DISTANCE_DESC) {
|
||||
modeToSet = MapMarkersOrderByMode.DISTANCE_ASC;
|
||||
} else {
|
||||
modeToSet = MapMarkersOrderByMode.DISTANCE_DESCENDINGLY;
|
||||
modeToSet = MapMarkersOrderByMode.DISTANCE_DESC;
|
||||
}
|
||||
break;
|
||||
case R.id.name_row:
|
||||
modeToSet = MapMarkersOrderByMode.NAME;
|
||||
break;
|
||||
case R.id.date_added_row:
|
||||
if (currentOrderByMode == MapMarkersOrderByMode.DATE_ADDED_DESCENDINGLY) {
|
||||
modeToSet = MapMarkersOrderByMode.DATE_ADDED_ASCENDINGLY;
|
||||
if (currentOrderByMode == MapMarkersOrderByMode.DATE_ADDED_DESC) {
|
||||
modeToSet = MapMarkersOrderByMode.DATE_ADDED_ASC;
|
||||
} else {
|
||||
modeToSet = MapMarkersOrderByMode.DATE_ADDED_DESCENDINGLY;
|
||||
modeToSet = MapMarkersOrderByMode.DATE_ADDED_DESC;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue