diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java index 199c76a01b..ca0af55967 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java @@ -123,6 +123,12 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL return null; } + void setShowDirectionEnabled(boolean showDirectionEnabled) { + if (adapter != null) { + adapter.setShowDirectionEnabled(showDirectionEnabled); + } + } + void updateAdapter() { if (adapter != null) { adapter.notifyDataSetChanged(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 14852d01ba..dc4c5c25f7 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -215,8 +215,10 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm final MapActivity mapActivity = getMapActivity(); @Override - public void onMapMarkersModeChanged() { + public void onMapMarkersModeChanged(boolean showDirectionEnabled) { mapActivity.getMapLayers().getMapWidgetRegistry().updateMapMarkersMode(mapActivity); + activeFragment.setShowDirectionEnabled(showDirectionEnabled); + activeFragment.updateAdapter(); } }; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java index 4c2d249e3c..43148b2a13 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java @@ -206,30 +206,34 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra public void onClick(View view) { OsmandSettings.MapMarkersMode previousMode = getMyApplication().getSettings().MAP_MARKERS_MODE.get(); highlightSelectedItem(previousMode, false); + boolean showDirectionEnabled = false; switch (view.getId()) { case R.id.top_bar_image: case R.id.top_bar_row: getMyApplication().getSettings().MAP_MARKERS_MODE.set(OsmandSettings.MapMarkersMode.TOOLBAR); highlightSelectedItem(OsmandSettings.MapMarkersMode.TOOLBAR, true); + showDirectionEnabled = true; break; case R.id.widget_image: case R.id.widget_row: getMyApplication().getSettings().MAP_MARKERS_MODE.set(OsmandSettings.MapMarkersMode.WIDGETS); highlightSelectedItem(OsmandSettings.MapMarkersMode.WIDGETS, true); + showDirectionEnabled = true; break; case R.id.none_row: getMyApplication().getSettings().MAP_MARKERS_MODE.set(OsmandSettings.MapMarkersMode.NONE); highlightSelectedItem(OsmandSettings.MapMarkersMode.NONE, true); + showDirectionEnabled = false; break; } if (listener != null) { - listener.onMapMarkersModeChanged(); + listener.onMapMarkersModeChanged(showDirectionEnabled); } dismiss(); } }; interface ShowDirectionFragmentListener { - void onMapMarkersModeChanged(); + void onMapMarkersModeChanged(boolean showDirectionEnabled); } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java index 6128ee4c83..b16a7470a9 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersActiveAdapter.java @@ -14,6 +14,7 @@ import android.widget.TextView; import net.osmand.data.LatLon; import net.osmand.plus.IconsCache; import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.dashboard.DashLocationFragment; @@ -31,6 +32,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter markers; private MapMarkersActiveAdapterListener listener; private Snackbar snackbar; + private boolean showDirectionEnabled; private LatLon location; private Float heading; @@ -42,6 +44,11 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter 1) { + if (showDirectionEnabled && position < 2 && getItemCount() > 1) { notifyItemChanged(1); } else if (position == getItemCount()) { notifyItemChanged(position - 1); @@ -167,7 +174,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter 2) { + if (showDirectionEnabled && position < 2 && getItemCount() > 2) { notifyItemChanged(2); } else if (position == getItemCount() - 1) { notifyItemChanged(position - 1);