Search in sources :

Example 1 with PleaseApplyNodeRefPositionChange

use of io.jawg.osmcontributor.ui.events.edition.PleaseApplyNodeRefPositionChange in project osm-contributor by jawg.

the class MapFragment method confirmPosition.

private void confirmPosition() {
    LatLng newPoiPosition;
    LatLng pos;
    switch(mapMode) {
        case POI_CREATION:
            if (getZoomLevel() < zoomVectorial) {
                changeMapZoomSmooth(15d);
            }
            createPoi();
            break;
        case NOTE_CREATION:
            pos = mapboxMap.getCameraPosition().target;
            NoteCommentDialogFragment dialog = NoteCommentDialogFragment.newInstance(pos.getLatitude(), pos.getLongitude());
            dialog.show(getActivity().getFragmentManager(), "dialog");
            break;
        case POI_POSITION_EDITION:
            Poi poi = (Poi) markerSelected.getRelatedObject();
            newPoiPosition = mapboxMap.getCameraPosition().target;
            eventBus.post(new PleaseApplyPoiPositionChange(newPoiPosition, poi.getId()));
            markerSelected.setPosition(newPoiPosition);
            markerSelected.setIcon(IconFactory.getInstance(getActivity()).fromBitmap(bitmapHandler.getMarkerBitmap(poi.getType(), Poi.computeState(false, false, true))));
            poi.setUpdated(true);
            mapboxMap.updateMarker(markerSelected);
            switchMode(MapMode.DETAIL_POI);
            break;
        case NODE_REF_POSITION_EDITION:
            PoiNodeRef poiNodeRef = wayMarkerSelected.getPoiNodeRef();
            newPoiPosition = mapboxMap.getCameraPosition().target;
            eventBus.post(new PleaseApplyNodeRefPositionChange(newPoiPosition, poiNodeRef.getId()));
            wayMarkerSelected.setPosition(newPoiPosition);
            wayMarkerSelected.setIcon(IconFactory.getInstance(getActivity()).fromBitmap(bitmapHandler.getNodeRefBitmap(PoiNodeRef.State.SELECTED)));
            removePolyline(editionPolyline);
            switchMode(MapMode.WAY_EDITION);
            break;
        case DETAIL_POI:
            getActivity().finish();
            break;
        default:
            break;
    }
}
Also used : PleaseApplyNodeRefPositionChange(io.jawg.osmcontributor.ui.events.edition.PleaseApplyNodeRefPositionChange) PleaseApplyPoiPositionChange(io.jawg.osmcontributor.ui.events.edition.PleaseApplyPoiPositionChange) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) Poi(io.jawg.osmcontributor.model.entities.Poi) PoiNodeRef(io.jawg.osmcontributor.model.entities.PoiNodeRef) NoteCommentDialogFragment(io.jawg.osmcontributor.ui.dialogs.NoteCommentDialogFragment)

Aggregations

LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1 Poi (io.jawg.osmcontributor.model.entities.Poi)1 PoiNodeRef (io.jawg.osmcontributor.model.entities.PoiNodeRef)1 NoteCommentDialogFragment (io.jawg.osmcontributor.ui.dialogs.NoteCommentDialogFragment)1 PleaseApplyNodeRefPositionChange (io.jawg.osmcontributor.ui.events.edition.PleaseApplyNodeRefPositionChange)1 PleaseApplyPoiPositionChange (io.jawg.osmcontributor.ui.events.edition.PleaseApplyPoiPositionChange)1