From fb428c931b89a35b596023bb1af826324ef9c223 Mon Sep 17 00:00:00 2001 From: veliymolfar Date: Tue, 25 Feb 2020 11:05:27 +0200 Subject: [PATCH] refactor duplicateItems --- OsmAnd/res/values/strings.xml | 2 +- OsmAnd/src/net/osmand/plus/SettingsHelper.java | 10 +--------- .../net/osmand/plus/helpers/AvoidSpecificRoads.java | 3 ++- .../plus/settings/ExportImportSettingsAdapter.java | 2 +- .../osmand/plus/settings/ImportDuplicatesFragment.java | 2 +- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 1552a0bf46..6984349329 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -72,7 +72,7 @@ Sunset at %1$s Sunrise at %1$s Routing - Rendering styles + Rendering style Include additional data The imported profile contains additional data. Click Import to import only profile data or select additional data to import. You can select additional data to export along with the profile. diff --git a/OsmAnd/src/net/osmand/plus/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/SettingsHelper.java index 5c1adc62a4..2746608dcc 100644 --- a/OsmAnd/src/net/osmand/plus/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/SettingsHelper.java @@ -246,7 +246,7 @@ public class SettingsHelper { public abstract static class CollectionSettingsItem extends SettingsItem { protected List items; - protected List duplicateItems; + protected List duplicateItems = new ArrayList<>(); protected List existingItems; CollectionSettingsItem(@NonNull SettingsItemType type, @NonNull List items) { @@ -859,7 +859,6 @@ public class SettingsHelper { this.app = app; actionRegistry = app.getQuickActionRegistry(); existingItems = actionRegistry.getQuickActions(); - duplicateItems = new ArrayList<>(); } QuickActionSettingsItem(@NonNull OsmandApplication app, @@ -868,7 +867,6 @@ public class SettingsHelper { this.app = app; actionRegistry = app.getQuickActionRegistry(); existingItems = actionRegistry.getQuickActions(); - duplicateItems = new ArrayList<>(); } @Override @@ -1027,14 +1025,12 @@ public class SettingsHelper { super(SettingsItemType.POI_UI_FILTERS, items); this.app = app; existingItems = app.getPoiFilters().getUserDefinedPoiFilters(false); - duplicateItems = new ArrayList<>(); } PoiUiFilterSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { super(SettingsItemType.POI_UI_FILTERS, json); this.app = app; existingItems = app.getPoiFilters().getUserDefinedPoiFilters(false); - duplicateItems = new ArrayList<>(); } @Override @@ -1199,7 +1195,6 @@ public class SettingsHelper { this.app = app; Collection values = new LinkedHashMap<>(app.getSettings().getTileSourceEntries(true)).values(); existingItemsNames = new ArrayList(values); - duplicateItems = new ArrayList<>(); } MapSourcesSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { @@ -1207,7 +1202,6 @@ public class SettingsHelper { this.app = app; Collection values = new LinkedHashMap<>(app.getSettings().getTileSourceEntries(true)).values(); existingItemsNames = new ArrayList(values); - duplicateItems = new ArrayList<>(); } @Override @@ -1429,7 +1423,6 @@ public class SettingsHelper { settings = app.getSettings(); specificRoads = app.getAvoidSpecificRoads(); existingItems = new ArrayList<>(specificRoads.getImpassableRoads().values()); - duplicateItems = new ArrayList<>(); } AvoidRoadsSettingsItem(@NonNull OsmandApplication app, @NonNull JSONObject json) throws JSONException { @@ -1438,7 +1431,6 @@ public class SettingsHelper { settings = app.getSettings(); specificRoads = app.getAvoidSpecificRoads(); existingItems = new ArrayList<>(specificRoads.getImpassableRoads().values()); - duplicateItems = new ArrayList<>(); } @NonNull diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java index 152f172ff2..86ba6ebe0e 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java +++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java @@ -37,6 +37,7 @@ import net.osmand.plus.routing.RoutingHelper.RouteSegmentSearchResult; import net.osmand.plus.views.ContextMenuLayer; import net.osmand.router.RouteSegmentResult; import net.osmand.router.RoutingConfiguration; +import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import java.util.ArrayList; @@ -415,7 +416,7 @@ public class AvoidSpecificRoads { AvoidRoadInfo other = (AvoidRoadInfo) obj; return Math.abs(latitude - other.latitude) < 0.00001 && Math.abs(longitude - other.longitude) < 0.00001 - && name.equals(other.name); + && Algorithms.objectEquals(name, other.name); } } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/ExportImportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/ExportImportSettingsAdapter.java index 9e097c8caa..74aa1ac59e 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ExportImportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/ExportImportSettingsAdapter.java @@ -281,7 +281,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { case MAP_SOURCES: return R.string.quick_action_map_source_title; case CUSTOM_RENDER_STYLE: - return R.string.shared_string_custom_rendering_style; + return R.string.shared_string_rendering_style; case CUSTOM_ROUTING: return R.string.shared_string_routing; case AVOID_ROADS: diff --git a/OsmAnd/src/net/osmand/plus/settings/ImportDuplicatesFragment.java b/OsmAnd/src/net/osmand/plus/settings/ImportDuplicatesFragment.java index 23a82b0390..9f80485955 100644 --- a/OsmAnd/src/net/osmand/plus/settings/ImportDuplicatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/ImportDuplicatesFragment.java @@ -182,7 +182,7 @@ public class ImportDuplicatesFragment extends BaseOsmAndFragment implements View duplicates.addAll(routingFilesList); } if (!renderFilesList.isEmpty()) { - duplicates.add(getString(R.string.shared_string_custom_rendering_style)); + duplicates.add(getString(R.string.shared_string_rendering_style)); duplicates.addAll(renderFilesList); } if (!avoidRoads.isEmpty()) {