From b60130f7e83421b53db42b66fe0d90c02109444c Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Wed, 21 Mar 2018 14:50:49 +0200 Subject: [PATCH] Remove unnecessary method from MapMarkersHelper --- .../src/net/osmand/plus/MapMarkersHelper.java | 32 +++++++------------ .../AddGroupBottomSheetDialogFragment.java | 4 +-- .../adapters/MapMarkersActiveAdapter.java | 2 +- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 6f3e7af6d3..9b8b3d9288 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -356,6 +356,9 @@ public class MapMarkersHelper { } public void updateGroup(MapMarkersGroup mapMarkersGroup) { + if (mapMarkersGroup.getId() == null || mapMarkersGroup.getName() == null) { + return; + } createHeaderInGroup(mapMarkersGroup); int historyMarkersCount = mapMarkersGroup.getHistoryMarkers().size(); ShowHideHistoryButton showHideHistoryButton = mapMarkersGroup.getShowHideHistoryButton(); @@ -399,21 +402,19 @@ public class MapMarkersHelper { } private void createHeaderInGroup(@NonNull MapMarkersGroup group) { - if (group.getName() != null) { - GroupHeader header = new GroupHeader(); - int type = group.getType(); - if (type != -1) { - header.iconRes = type == MapMarkersGroup.FAVORITES_TYPE - ? R.drawable.ic_action_fav_dark : R.drawable.ic_action_polygom_dark; - } - header.group = group; - group.header = header; + GroupHeader header = new GroupHeader(); + int type = group.getType(); + if (type != -1) { + header.iconRes = type == MapMarkersGroup.FAVORITES_TYPE + ? R.drawable.ic_action_fav_dark : R.drawable.ic_action_polygom_dark; } + header.group = group; + group.header = header; } private void removeMarkerFromGroup(MapMarker marker) { if (marker != null) { - MapMarkersGroup mapMarkersGroup = getMapMarkerGroupByName(marker.groupName); + MapMarkersGroup mapMarkersGroup = getMapMarkerGroupById(marker.groupKey); if (mapMarkersGroup != null) { mapMarkersGroup.getMarkers().remove(marker); updateGroup(mapMarkersGroup); @@ -434,17 +435,6 @@ public class MapMarkersHelper { } } - @Nullable - public MapMarkersGroup getMapMarkerGroupByName(String name) { - for (MapMarkersGroup group : mapMarkersGroups) { - if ((name == null && group.getName() == null) - || (group.getName() != null && group.getName().equals(name))) { - return group; - } - } - return null; - } - @Nullable public MapMarkersGroup getMapMarkerGroupById(String id) { for (MapMarkersGroup group : mapMarkersGroups) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java index 28dabcda4a..de6cb5448d 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java @@ -8,8 +8,8 @@ import android.support.v7.widget.RecyclerView; import android.view.ContextThemeWrapper; import android.view.View; -import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; +import net.osmand.plus.MapMarkersHelper.OnGroupSyncedListener; import net.osmand.plus.R; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; @@ -60,7 +60,7 @@ public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetD } protected void addAndSyncGroup(MapMarkersGroup group) { - getMyApplication().getMapMarkersHelper().addAndSyncGroup(group, new MapMarkersHelper.OnGroupSyncedListener() { + getMyApplication().getMapMarkersHelper().addAndSyncGroup(group, new OnGroupSyncedListener() { @Override public void onSyncDone() { Fragment parent = getParentFragment(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index 92c995bdd9..3d4789ba55 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -237,7 +237,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter