Add functionality to use location item

This commit is contained in:
Alexander Sytnyk 2017-09-28 15:18:31 +03:00
parent 20a99ac9c6
commit ca92958259

View file

@ -138,11 +138,13 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
@Override @Override
public void onClick(View view) { public void onClick(View view) {
int activeMarkersCount = markersHelper.getMapMarkers().size(); int activeMarkersCount = markersHelper.getMapMarkers().size();
if (selectedCount == activeMarkersCount) { if (selectedCount == activeMarkersCount && markersHelper.isStartFromMyLocation()) {
markersHelper.deselectAllActiveMarkers(); markersHelper.deselectAllActiveMarkers();
markersHelper.setStartFromMyLocation(false);
selectedCount = 0; selectedCount = 0;
} else { } else {
markersHelper.selectAllActiveMarkers(); markersHelper.selectAllActiveMarkers();
markersHelper.setStartFromMyLocation(true);
selectedCount = activeMarkersCount; selectedCount = activeMarkersCount;
} }
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
@ -197,7 +199,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
public void onItemClick(View view) { public void onItemClick(View view) {
int pos = markersRv.getChildAdapterPosition(view); int pos = markersRv.getChildAdapterPosition(view);
if (pos == 0) { if (pos == 0) {
Toast.makeText(mapActivity, "location selected", Toast.LENGTH_SHORT).show(); markersHelper.setStartFromMyLocation(!mapActivity.getMyApplication().getSettings().ROUTE_MAP_MARKERS_START_MY_LOC.get());
} else { } else {
MapMarker marker = adapter.getItem(pos); MapMarker marker = adapter.getItem(pos);
selectedCount = marker.selected ? selectedCount - 1 : selectedCount + 1; selectedCount = marker.selected ? selectedCount - 1 : selectedCount + 1;
@ -422,7 +424,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
} }
private void updateSelectButton() { private void updateSelectButton() {
if (selectedCount == markersHelper.getMapMarkers().size()) { if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) {
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all)); ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all));
} else { } else {
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all)); ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all));