Add opening of marker menu on map from groups
This commit is contained in:
parent
e19731c25a
commit
6603af405c
2 changed files with 37 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<RecyclerView.V
|
|||
private List<MapMarker> 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<RecyclerView.V
|
|||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
if (viewType == MARKER_TYPE) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
|
||||
view.setClickable(true);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
listener.onItemClick(view);
|
||||
}
|
||||
});
|
||||
return new MapMarkerItemViewHolder(view);
|
||||
} else if (viewType == HEADER_TYPE) {
|
||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_header, viewGroup, false);
|
||||
|
@ -476,4 +487,9 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
public interface MapMarkersGroupsAdapterListener {
|
||||
|
||||
void onItemClick(View view);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue