refactor duplicateItems

This commit is contained in:
veliymolfar 2020-02-25 11:05:27 +02:00
parent 4fc18f0783
commit fb428c931b
5 changed files with 6 additions and 13 deletions

View file

@ -72,7 +72,7 @@
<string name="sunset_at">Sunset at %1$s</string>
<string name="sunrise_at">Sunrise at %1$s</string>
<string name="shared_string_routing">Routing</string>
<string name="shared_string_custom_rendering_style">Rendering styles</string>
<string name="shared_string_rendering_style">Rendering style</string>
<string name="shared_string_include_data">Include additional data</string>
<string name="import_profile_dialog_description">The imported profile contains additional data. Click Import to import only profile data or select additional data to import.</string>
<string name="export_profile_dialog_description">You can select additional data to export along with the profile.</string>

View file

@ -246,7 +246,7 @@ public class SettingsHelper {
public abstract static class CollectionSettingsItem<T> extends SettingsItem {
protected List<T> items;
protected List<T> duplicateItems;
protected List<T> duplicateItems = new ArrayList<>();
protected List<T> existingItems;
CollectionSettingsItem(@NonNull SettingsItemType type, @NonNull List<T> 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

View file

@ -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);
}
}
}

View file

@ -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:

View file

@ -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()) {