refactor
This commit is contained in:
parent
71c3ce5b98
commit
e62b2f1d4c
3 changed files with 25 additions and 18 deletions
|
@ -107,9 +107,9 @@ public class SQLiteTileSource implements ITileSource {
|
||||||
this.inversiveZoom = inversiveZoom;
|
this.inversiveZoom = inversiveZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLiteTileSource(SQLiteTileSource tileSource, int suffixNum, OsmandApplication ctx) {
|
public SQLiteTileSource(SQLiteTileSource tileSource, String name, OsmandApplication ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.name = tileSource.getName() + "_" + suffixNum;
|
this.name = name;
|
||||||
this.urlTemplate = tileSource.getUrlTemplate();
|
this.urlTemplate = tileSource.getUrlTemplate();
|
||||||
this.maxZoom = tileSource.getMaximumZoomSupported();
|
this.maxZoom = tileSource.getMaximumZoomSupported();
|
||||||
this.minZoom = tileSource.getMinimumZoomSupported();
|
this.minZoom = tileSource.getMinimumZoomSupported();
|
||||||
|
|
|
@ -260,10 +260,10 @@ public class SettingsHelper {
|
||||||
@NonNull
|
@NonNull
|
||||||
public abstract List<T> excludeDuplicateItems();
|
public abstract List<T> excludeDuplicateItems();
|
||||||
|
|
||||||
public abstract boolean isDuplicate(T item);
|
public abstract boolean isDuplicate(@NonNull T item);
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public abstract T renameItem(T item);
|
public abstract T renameItem(@NonNull T item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class SettingsItemReader<T extends SettingsItem> {
|
public abstract static class SettingsItemReader<T extends SettingsItem> {
|
||||||
|
@ -854,13 +854,13 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDuplicate(QuickAction item) {
|
public boolean isDuplicate(@NonNull QuickAction item) {
|
||||||
return !actionRegistry.isNameUnique(item, app);
|
return !actionRegistry.isNameUnique(item, app);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public QuickAction renameItem(QuickAction item) {
|
public QuickAction renameItem(@NonNull QuickAction item) {
|
||||||
return actionRegistry.generateUniqueName(item, app);
|
return actionRegistry.generateUniqueName(item, app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -898,7 +898,7 @@ public class SettingsHelper {
|
||||||
newActions.addAll(duplicateItems);
|
newActions.addAll(duplicateItems);
|
||||||
}
|
}
|
||||||
newActions.addAll(items);
|
newActions.addAll(items);
|
||||||
app.getQuickActionRegistry().updateQuickActions(newActions);
|
actionRegistry.updateQuickActions(newActions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1044,7 +1044,7 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDuplicate(PoiUIFilter item) {
|
public boolean isDuplicate(@NonNull PoiUIFilter item) {
|
||||||
String savedName = item.getName();
|
String savedName = item.getName();
|
||||||
for (PoiUIFilter filter : existingItems) {
|
for (PoiUIFilter filter : existingItems) {
|
||||||
if (filter.getName().equals(savedName)) {
|
if (filter.getName().equals(savedName)) {
|
||||||
|
@ -1072,11 +1072,13 @@ public class SettingsHelper {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public PoiUIFilter renameItem(PoiUIFilter item) {
|
public PoiUIFilter renameItem(@NonNull PoiUIFilter item) {
|
||||||
int number = 0;
|
int number = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
number++;
|
number++;
|
||||||
PoiUIFilter renamedItem = new PoiUIFilter(item, number, app);
|
PoiUIFilter renamedItem = new PoiUIFilter(item,
|
||||||
|
item.getName() + "_" + number,
|
||||||
|
item.getFilterId() + "_" + number);
|
||||||
if (!isDuplicate(renamedItem)) {
|
if (!isDuplicate(renamedItem)) {
|
||||||
return renamedItem;
|
return renamedItem;
|
||||||
}
|
}
|
||||||
|
@ -1269,13 +1271,16 @@ public class SettingsHelper {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ITileSource renameItem(ITileSource item) {
|
public ITileSource renameItem(@NonNull ITileSource item) {
|
||||||
int number = 0;
|
int number = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
number++;
|
number++;
|
||||||
if (item instanceof SQLiteTileSource) {
|
if (item instanceof SQLiteTileSource) {
|
||||||
SQLiteTileSource oldItem = (SQLiteTileSource) item;
|
SQLiteTileSource oldItem = (SQLiteTileSource) item;
|
||||||
SQLiteTileSource renamedItem = new SQLiteTileSource(oldItem, number, app);
|
SQLiteTileSource renamedItem = new SQLiteTileSource(
|
||||||
|
oldItem,
|
||||||
|
oldItem.getName() + "_" + number,
|
||||||
|
app);
|
||||||
if (!isDuplicate(renamedItem)) {
|
if (!isDuplicate(renamedItem)) {
|
||||||
return renamedItem;
|
return renamedItem;
|
||||||
}
|
}
|
||||||
|
@ -1290,7 +1295,7 @@ public class SettingsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDuplicate(ITileSource item) {
|
public boolean isDuplicate(@NonNull ITileSource item) {
|
||||||
for (String name : existingItemsNames) {
|
for (String name : existingItemsNames) {
|
||||||
if (name.equals(item.getName())) {
|
if (name.equals(item.getName())) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -125,14 +125,16 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
|
||||||
name = app.getPoiFilters().getFiltersName(filtersToMerge);
|
name = app.getPoiFilters().getFiltersName(filtersToMerge);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiUIFilter(PoiUIFilter filter, int suffixNum, OsmandApplication app) {
|
public PoiUIFilter(PoiUIFilter filter, String name, String filterId) {
|
||||||
this.app = app;
|
this.app = filter.app;
|
||||||
name = filter.getName() + "_" + suffixNum;
|
this.name = name;
|
||||||
filterId = filter.getFilterId() + "_" + suffixNum;
|
this.filterId = filterId;
|
||||||
isStandardFilter = false;
|
isStandardFilter = false;
|
||||||
poiTypes = app.getPoiTypes();
|
poiTypes = filter.poiTypes;
|
||||||
acceptedTypes = filter.getAcceptedTypes();
|
acceptedTypes = filter.getAcceptedTypes();
|
||||||
poiAdditionals = filter.getPoiAdditionals();
|
poiAdditionals = filter.getPoiAdditionals();
|
||||||
|
filterByName = filter.filterByName;
|
||||||
|
savedFilterByName = filter.savedFilterByName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
|
|
Loading…
Reference in a new issue