use of net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter.MeasurementAdapterListener in project Osmand by osmandapp.
the class MeasurementToolFragment method createMeasurementAdapterListener.
private MeasurementAdapterListener createMeasurementAdapterListener(final ItemTouchHelper touchHelper) {
return new MeasurementAdapterListener() {
final MapActivity mapActivity = getMapActivity();
final MeasurementToolLayer measurementLayer = getMeasurementLayer();
private int fromPosition;
private int toPosition;
@Override
public void onRemoveClick(int position) {
if (measurementLayer != null) {
removePoint(measurementLayer, position);
}
}
@Override
public void onItemClick(int position) {
if (mapActivity != null && measurementLayer != null) {
if (pointsListOpened) {
hidePointsList();
}
OsmandMapTileView tileView = mapActivity.getMapView();
if (portrait) {
previousMapPosition = tileView.getMapPosition();
tileView.setMapPosition(MIDDLE_TOP_CONSTANT);
}
mapActivity.refreshMap();
measurementLayer.moveMapToPoint(position);
measurementLayer.selectPoint(position);
}
}
@Override
public void onDragStarted(RecyclerView.ViewHolder holder) {
fromPosition = holder.getAdapterPosition();
touchHelper.startDrag(holder);
}
@Override
public void onDragEnded(RecyclerView.ViewHolder holder) {
if (mapActivity != null && measurementLayer != null) {
toPosition = holder.getAdapterPosition();
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
editingCtx.getCommandManager().execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition));
adapter.notifyDataSetChanged();
disable(redoBtn);
updateText();
mapActivity.refreshMap();
saved = false;
}
}
}
};
}
Aggregations