From bb55f77e34efc38c90ce20d699d819e91d1e04f1 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 19 Oct 2017 12:01:45 +0300 Subject: [PATCH] Add opening of marker menu on map from groups --- .../mapmarkers/MapMarkersGroupsFragment.java | 19 ++++++++++++++++++ .../adapters/MapMarkersGroupsAdapter.java | 20 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java index 4db3ae33cd..88d51a7153 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java @@ -10,6 +10,7 @@ import android.graphics.Rect; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; +import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v7.widget.LinearLayoutManager; @@ -203,6 +204,24 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL itemTouchHelper.attachToRecyclerView(recyclerView); adapter = new MapMarkersGroupsAdapter(mapActivity); + adapter.setListener(new MapMarkersGroupsAdapter.MapMarkersGroupsAdapterListener() { + @Override + public void onItemClick(View view) { + int pos = recyclerView.getChildAdapterPosition(view); + if (pos == RecyclerView.NO_POSITION) { + return; + } + Object item = adapter.getItem(pos); + if (item instanceof MapMarker) { + MapMarker marker = (MapMarker) item; + mapActivity.getMyApplication().getSettings() + .setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), 15, null, false, null); + MapActivity.launchMapActivityMoveToTop(mapActivity); + MarkerMenuOnMapFragment.showInstance(mapActivity, marker); + ((DialogFragment) getParentFragment()).dismiss(); + } + } + }); recyclerView.setAdapter(adapter); return recyclerView; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java index 1876f3fb30..5a456521e9 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java @@ -12,9 +12,9 @@ import android.widget.TextView; import net.osmand.data.LatLon; import net.osmand.plus.IconsCache; +import net.osmand.plus.MapMarkersHelper.GroupHeader; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; -import net.osmand.plus.MapMarkersHelper.GroupHeader; import net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; @@ -52,6 +52,12 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter showDirectionMarkers; private Snackbar snackbar; + private MapMarkersGroupsAdapterListener listener; + + public void setListener(MapMarkersGroupsAdapterListener listener) { + this.listener = listener; + } + public MapMarkersGroupsAdapter(MapActivity mapActivity) { this.mapActivity = mapActivity; app = mapActivity.getMyApplication(); @@ -150,7 +156,12 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter