Add address for all favorites

This commit is contained in:
Dima-1 2020-01-08 19:01:02 +02:00
parent e5822cdf8e
commit 0963cd00f7

View file

@ -274,9 +274,6 @@ public class FavouritesDbHelper {
point.setAddress(address); point.setAddress(address);
addFavourite(point); addFavourite(point);
} }
if (address == null) {
lookupAddress(point);
}
} }
public boolean addFavourite(FavouritePoint p) { public boolean addFavourite(FavouritePoint p) {
@ -287,6 +284,9 @@ public class FavouritesDbHelper {
if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) { if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) {
return true; return true;
} }
if (!p.isAddressSpecified()) {
lookupAddress(p);
}
context.getSettings().SHOW_FAVORITES.set(true); context.getSettings().SHOW_FAVORITES.set(true);
FavoriteGroup group = getOrCreateGroup(p, 0); FavoriteGroup group = getOrCreateGroup(p, 0);
@ -305,16 +305,6 @@ public class FavouritesDbHelper {
return true; return true;
} }
public void lookupAddressAllSpecialPoints() {
if (!context.isApplicationInitializing()) {
for (FavouritePoint p : getFavouritePoints()) {
if (p.getSpecialPointType() != null) {
lookupAddress(p);
}
}
}
}
public void lookupAddress(@NonNull final FavouritePoint p) { public void lookupAddress(@NonNull final FavouritePoint p) {
AddressLookupRequest request = addressRequestMap.get(p); AddressLookupRequest request = addressRequestMap.get(p);
double latitude = p.getLatitude(); double latitude = p.getLatitude();
@ -446,34 +436,23 @@ public class FavouritesDbHelper {
} }
public boolean editAddressDescription(FavouritePoint p, String address) { private void editAddressDescription(@NonNull FavouritePoint p, @Nullable String address) {
p.setAddress(address); p.setAddress(address);
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
runSyncWithMarkers(getOrCreateGroup(p, 0)); runSyncWithMarkers(getOrCreateGroup(p, 0));
return true;
} }
public boolean editFavouriteDescription(FavouritePoint p, String description) { public boolean editFavourite(@NonNull FavouritePoint p, double lat, double lon) {
p.setDescription(description); return editFavourite(p, lat, lon, null);
saveCurrentPointsIntoFile();
runSyncWithMarkers(getOrCreateGroup(p, 0));
return true;
} }
public boolean editFavourite(FavouritePoint p, double lat, double lon) { private boolean editFavourite(@NonNull FavouritePoint p, double lat, double lon, @Nullable String description) {
cancelAddressRequest(p);
p.setLatitude(lat);
p.setLongitude(lon);
saveCurrentPointsIntoFile();
runSyncWithMarkers(getOrCreateGroup(p, 0));
return true;
}
public boolean editFavourite(FavouritePoint p, double lat, double lon, String description) {
cancelAddressRequest(p); cancelAddressRequest(p);
p.setLatitude(lat); p.setLatitude(lat);
p.setLongitude(lon); p.setLongitude(lon);
if (description != null) {
p.setDescription(description); p.setDescription(description);
}
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
runSyncWithMarkers(getOrCreateGroup(p, 0)); runSyncWithMarkers(getOrCreateGroup(p, 0));
return true; return true;