Search in sources :

Example 1 with PleaseChangeValuesDetailPoiFragmentEvent

use of io.jawg.osmcontributor.ui.events.map.PleaseChangeValuesDetailPoiFragmentEvent 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 2 with PleaseChangeValuesDetailPoiFragmentEvent

use of io.jawg.osmcontributor.ui.events.map.PleaseChangeValuesDetailPoiFragmentEvent in project osm-contributor by jawg.

the class MapFragmentPresenter method onLoaded.

private void onLoaded(List<MapElement> mapElements, LocationMarkerView.MarkerType markerType) {
    LocationMarkerView markerSelected = mapFragment.getMarkerSelected();
    for (MapElement mapElement : mapElements) {
        ids.add(mapElement.getId());
        LocationMarkerViewOptions markerOptions = mapFragment.getMarkerOptions(markerType, mapElement.getId());
        boolean selected = false;
        if (markerOptions == null) {
            markerOptions = new LocationMarkerViewOptions<>().relatedObject(mapElement).position(mapElement.getPosition());
            if (mapFragment.getSelectedMarkerType().equals(markerType) && mapElement.getId().equals(mapFragment.getMarkerSelectedId())) {
                selected = true;
                mapFragment.setMarkerSelected(markerOptions.getMarker());
            } else if (mapFragment.getSelectedMarkerType().equals(LocationMarkerView.MarkerType.POI) && markerSelected != null && mapElement.getId().equals(((Poi) markerSelected.getRelatedObject()).getId())) {
                selected = true;
            }
            // the poi in edition should be hidden
            if (!(markerSelected != null && mapFragment.getMapMode() == MapMode.POI_POSITION_EDITION && markerSelected.equals(markerOptions.getMarker())) && (mapElement instanceof Poi && !((Poi) mapElement).getToDelete())) {
                setIcon(markerOptions, mapElement, selected);
                mapFragment.addPoi(markerOptions);
            }
            if (markerType == LocationMarkerView.MarkerType.NOTE) {
                if (mapFragment.getSelectedMarkerType().equals(LocationMarkerView.MarkerType.NOTE) && mapElement.getId().equals(mapFragment.getMarkerSelectedId())) {
                    mapFragment.setMarkerSelected(markerOptions.getMarker());
                }
                setIcon(markerOptions, mapElement, false);
                mapFragment.addNote(markerOptions);
            }
        } else {
            if (markerType == LocationMarkerView.MarkerType.POI) {
                Poi poi = (Poi) mapElement;
                Poi oldPoi = (Poi) markerOptions.getMarker().getRelatedObject();
                oldPoi.setName(poi.getName());
                oldPoi.setUpdated(poi.getUpdated());
                selected = false;
                if (mapFragment.getSelectedMarkerType().equals(LocationMarkerView.MarkerType.POI) && (mapElement.getId().equals(mapFragment.getMarkerSelectedId()) || markerSelected != null && mapElement.getId().equals(((Poi) markerSelected.getRelatedObject()).getId()))) {
                    selected = true;
                }
                setIcon(markerOptions, oldPoi, selected);
            } else {
                if (mapFragment.getSelectedMarkerType().equals(LocationMarkerView.MarkerType.NOTE) && markerSelected != null && mapElement.getId().equals(((Note) markerSelected.getRelatedObject()).getId())) {
                    selected = true;
                }
                setIcon(markerOptions, mapElement, selected);
            }
            // update the detail banner data
            if (selected) {
                if (mapFragment.getMapMode() == MapMode.DETAIL_NOTE) {
                    eventBus.post(new PleaseChangeValuesDetailNoteFragmentEvent((Note) mapElement));
                } else {
                    Poi poi = (Poi) mapElement;
                    eventBus.post(new PleaseChangeValuesDetailPoiFragmentEvent(poi));
                }
            }
        }
    }
    if ((mapFragment.getMapMode() == MapMode.DEFAULT || mapFragment.getMapMode() == MapMode.POI_CREATION)) {
        mapFragment.reselectMarker();
    }
    if (mapFragment.getSelectedMarkerType().equals(markerType) && markerSelected == null) {
        mapFragment.setMarkerSelectedId(-1L);
    }
}
Also used : MapElement(io.jawg.osmcontributor.utils.core.MapElement) LocationMarkerViewOptions(io.jawg.osmcontributor.ui.utils.views.map.marker.LocationMarkerViewOptions) Note(io.jawg.osmcontributor.model.entities.Note) PleaseChangeValuesDetailPoiFragmentEvent(io.jawg.osmcontributor.ui.events.map.PleaseChangeValuesDetailPoiFragmentEvent) Poi(io.jawg.osmcontributor.model.entities.Poi) LocationMarkerView(io.jawg.osmcontributor.ui.utils.views.map.marker.LocationMarkerView) PleaseChangeValuesDetailNoteFragmentEvent(io.jawg.osmcontributor.ui.events.map.PleaseChangeValuesDetailNoteFragmentEvent)

Aggregations

Poi (io.jawg.osmcontributor.model.entities.Poi)2 PleaseChangeValuesDetailPoiFragmentEvent (io.jawg.osmcontributor.ui.events.map.PleaseChangeValuesDetailPoiFragmentEvent)2 Animation (android.view.animation.Animation)1 Note (io.jawg.osmcontributor.model.entities.Note)1 PleaseChangeValuesDetailNoteFragmentEvent (io.jawg.osmcontributor.ui.events.map.PleaseChangeValuesDetailNoteFragmentEvent)1 LocationMarkerView (io.jawg.osmcontributor.ui.utils.views.map.marker.LocationMarkerView)1 LocationMarkerViewOptions (io.jawg.osmcontributor.ui.utils.views.map.marker.LocationMarkerViewOptions)1 MapElement (io.jawg.osmcontributor.utils.core.MapElement)1