Search in sources :

Example 21 with Poi

use of io.jawg.osmcontributor.model.entities.Poi 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)

Example 22 with Poi

use of io.jawg.osmcontributor.model.entities.Poi in project osm-contributor by jawg.

the class MapFragment method displayPoiDetailBanner.

/*-----------------------------------------------------------
    * POI DETAIL
    *---------------------------------------------------------*/
private void displayPoiDetailBanner(boolean display) {
    if (display) {
        if (markerSelected != null) {
            Poi poi = (Poi) markerSelected.getRelatedObject();
            eventBus.post(new PleaseChangeValuesDetailPoiFragmentEvent(poi));
        }
        if (poiDetailWrapper.getVisibility() != View.VISIBLE) {
            Animation bottomUp = AnimationUtils.loadAnimation(getActivity(), R.anim.anim_up_detail);
            poiDetailWrapper.startAnimation(bottomUp);
            poiDetailWrapper.setVisibility(View.VISIBLE);
        }
    } else {
        if (poiDetailWrapper.getVisibility() == View.VISIBLE) {
            Animation upDown = AnimationUtils.loadAnimation(getActivity(), R.anim.anim_down_detail);
            poiDetailWrapper.startAnimation(upDown);
            poiDetailWrapper.setVisibility(View.GONE);
        }
    }
}
Also used : Animation(android.view.animation.Animation) PleaseChangeValuesDetailPoiFragmentEvent(io.jawg.osmcontributor.ui.events.map.PleaseChangeValuesDetailPoiFragmentEvent) Poi(io.jawg.osmcontributor.model.entities.Poi)

Example 23 with Poi

use of io.jawg.osmcontributor.model.entities.Poi in project osm-contributor by jawg.

the class MapFragment method onPleaseDeletePoiFromMapEvent.

/*-----------------------------------------------------------
    * POI DELETION
    *---------------------------------------------------------*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPleaseDeletePoiFromMapEvent(PleaseDeletePoiFromMapEvent event) {
    Poi poi = (Poi) markerSelected.getRelatedObject();
    poi.setToDelete(true);
    removeMarkerView(markersPoi.get(poi.getId()));
    markersPoi.remove(poi.getId());
    eventBus.post(new PleaseDeletePoiEvent(poi));
    OsmAnswers.localPoiAction(poi.getType().getTechnicalName(), "delete");
    switchMode(MapMode.DEFAULT);
}
Also used : PleaseDeletePoiEvent(io.jawg.osmcontributor.model.events.PleaseDeletePoiEvent) Poi(io.jawg.osmcontributor.model.entities.Poi) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 24 with Poi

use of io.jawg.osmcontributor.model.entities.Poi in project osm-contributor by jawg.

the class MapFragment method unselectMarker.

public void unselectMarker() {
    if (markerSelected != null) {
        Bitmap bitmap = null;
        switch(markerSelected.getType()) {
            case POI:
                Poi poi = (Poi) markerSelected.getRelatedObject();
                bitmap = bitmapHandler.getMarkerBitmap(poi.getType(), Poi.computeState(false, false, poi.getUpdated()));
                break;
            case NOTE:
                bitmap = bitmapHandler.getNoteBitmap(Note.computeState((Note) markerSelected.getRelatedObject(), false, false));
                break;
            default:
                break;
        }
        if (bitmap != null) {
            markerSelected.setIcon(IconFactory.getInstance(getActivity()).fromBitmap(bitmap));
        }
        markerSelectedId = -1L;
        markerSelected = null;
    }
}
Also used : Bitmap(android.graphics.Bitmap) Poi(io.jawg.osmcontributor.model.entities.Poi)

Example 25 with Poi

use of io.jawg.osmcontributor.model.entities.Poi in project osm-contributor by jawg.

the class EditPoiManager method saveOldVersionOfPoi.

private Long saveOldVersionOfPoi(Poi poi) {
    if (poi.getBackendId() == null) {
        return null;
    }
    if (poiManager.countForBackendId(poi.getBackendId()) == 1) {
        Poi old = poi.getCopy();
        old.setOld(true);
        poiManager.savePoi(old);
        return old.getId();
    }
    return poi.getOldPoiId();
}
Also used : Poi(io.jawg.osmcontributor.model.entities.Poi)

Aggregations

Poi (io.jawg.osmcontributor.model.entities.Poi)36 ArrayList (java.util.ArrayList)9 Subscribe (org.greenrobot.eventbus.Subscribe)9 HashMap (java.util.HashMap)7 PoiNodeRef (io.jawg.osmcontributor.model.entities.PoiNodeRef)5 Bitmap (android.graphics.Bitmap)3 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)3 PoiTag (io.jawg.osmcontributor.model.entities.PoiTag)3 Note (io.jawg.osmcontributor.model.entities.Note)2 PoiType (io.jawg.osmcontributor.model.entities.PoiType)2 PoiTypeTag (io.jawg.osmcontributor.model.entities.PoiTypeTag)2 PoiForEditionLoadedEvent (io.jawg.osmcontributor.model.events.PoiForEditionLoadedEvent)2 OsmDto (io.jawg.osmcontributor.rest.dtos.osm.OsmDto)2 PoiChangesApplyEvent (io.jawg.osmcontributor.ui.events.edition.PoiChangesApplyEvent)2 PleaseChangeValuesDetailPoiFragmentEvent (io.jawg.osmcontributor.ui.events.map.PleaseChangeValuesDetailPoiFragmentEvent)2 PoiManager (io.jawg.osmcontributor.ui.managers.PoiManager)2 MapElement (io.jawg.osmcontributor.utils.core.MapElement)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2