use of net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType in project Osmand by osmandapp.
the class AddPointBottomSheetDialog method getAdapterOnClickListener.
private OnClickListener getAdapterOnClickListener(final List<Object> items) {
return new OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = (MapActivity) getActivity();
RecyclerView.ViewHolder viewHolder = (RecyclerView.ViewHolder) v.getTag();
int position = viewHolder != null ? viewHolder.getAdapterPosition() : RecyclerView.NO_POSITION;
if (mapActivity == null || position == RecyclerView.NO_POSITION) {
return;
}
Object item = items.get(position);
if (item.equals(FAVORITES)) {
openFavoritesDialog();
} else if (item.equals(MARKERS)) {
MapRouteInfoMenu menu = mapActivity.getMapRouteInfoMenu();
menu.selectMapMarker(-1, pointType);
dismiss();
} else if (item instanceof MapMarker) {
MapRouteInfoMenu menu = mapActivity.getMapRouteInfoMenu();
menu.selectMapMarker((MapMarker) item, pointType);
dismiss();
} else {
TargetPointsHelper targetPointsHelper = mapActivity.getMyApplication().getTargetPointsHelper();
Pair<LatLon, PointDescription> pair = getLocationAndDescrFromItem(item);
LatLon ll = pair.first;
PointDescription name = pair.second;
if (ll == null) {
if (item instanceof PointType) {
AddPointBottomSheetDialog.showInstance(mapActivity, (PointType) item);
} else {
dismiss();
}
} else {
FavouritesHelper favorites = requiredMyApplication().getFavoritesHelper();
switch(pointType) {
case START:
targetPointsHelper.setStartPoint(ll, true, name);
break;
case TARGET:
targetPointsHelper.navigateToPoint(ll, true, -1, name);
break;
case INTERMEDIATE:
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), name);
break;
case HOME:
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.HOME, null);
break;
case WORK:
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.WORK, null);
break;
case PARKING:
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.PARKING, null);
break;
}
dismiss();
}
}
}
};
}
use of net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType in project Osmand by osmandapp.
the class AddPointBottomSheetDialog method getLocationAndDescrFromItem.
private Pair<LatLon, PointDescription> getLocationAndDescrFromItem(Object item) {
PointDescription name = null;
LatLon ll = null;
if (item instanceof FavouritePoint) {
FavouritePoint point = (FavouritePoint) item;
ll = new LatLon(point.getLatitude(), point.getLongitude());
name = point.getPointDescription(requireActivity());
} else if (item instanceof PointType) {
MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
FavouritesHelper favorites = mapActivity.getMyApplication().getFavoritesHelper();
FavouritePoint point = null;
if (item == PointType.HOME) {
point = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.HOME);
} else if (item == PointType.WORK) {
point = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.WORK);
} else if (item == PointType.PARKING) {
point = favorites.getSpecialPoint(FavouritePoint.SpecialPointType.PARKING);
}
if (point != null) {
ll = new LatLon(point.getLatitude(), point.getLongitude());
name = point.getPointDescription(mapActivity);
}
}
}
return new Pair<>(ll, name);
}
Aggregations