Search in sources :

Example 16 with Poi

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

the class PhotoActivity method initView.

private void initView() {
    poiId = getIntent().getLongExtra("poiId", 0);
    if (ImageAdapter.getPhotoUrlsCachedThumbs(poiId) == null || ImageAdapter.getPhotoUrlsCachedThumbs(poiId).isEmpty()) {
        gridPhotos.setVisibility(View.INVISIBLE);
        loadingImage.setVisibility(View.VISIBLE);
    }
    Poi currentPoi = application.getOsmTemplateComponent().getPoiManager().queryForId(poiId);
    asyncGetPhotos = new GetFlickrPhotos(longitude, latitude, application.getFlickr(), NB_IMAGE_REQUESTED, NB_PAGE_REQUESTED, currentPoi);
    asyncGetPhotos.execute();
}
Also used : GetFlickrPhotos(io.jawg.osmcontributor.flickr.rest.asynctask.GetFlickrPhotos) Poi(io.jawg.osmcontributor.model.entities.Poi)

Example 17 with Poi

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

the class PhotoActivity method defineImageOnPoi.

/**
 * Associate the newly uploaded flickr picture to the current Poi
 *
 * @param imageUrl The complete URL to access this picture
 */
private void defineImageOnPoi(String imageUrl) {
    if (imageUrl.length() > 0) {
        Poi currentPoi = application.getOsmTemplateComponent().getPoiManager().queryForId(poiId);
        Map<String, String> currentPoiTagsMap = new HashMap<String, String>(currentPoi.getTagsMap());
        if (currentPoiTagsMap.containsKey(OSM_FLICKR_TAG)) {
            StringBuilder newFlickrTag = new StringBuilder(currentPoiTagsMap.get(OSM_FLICKR_TAG).trim()).append(";").append(imageUrl);
            currentPoiTagsMap.put(OSM_FLICKR_TAG, newFlickrTag.toString());
        } else {
            currentPoiTagsMap.put(OSM_FLICKR_TAG, imageUrl);
        }
        PoiChanges currentPoiChanges = new PoiChanges(poiId);
        currentPoiChanges.setTagsMap(currentPoiTagsMap);
        eventBus.post(new PleaseApplyPoiChanges(currentPoiChanges));
    } else {
        Log.e(TAG, "Invalid Flickr URL: " + imageUrl);
    }
}
Also used : HashMap(java.util.HashMap) PoiChanges(io.jawg.osmcontributor.utils.edition.PoiChanges) PleaseApplyPoiChanges(io.jawg.osmcontributor.ui.events.edition.PleaseApplyPoiChanges) PleaseApplyPoiChanges(io.jawg.osmcontributor.ui.events.edition.PleaseApplyPoiChanges) Poi(io.jawg.osmcontributor.model.entities.Poi)

Example 18 with Poi

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

the class EditPoiManager method onPleaseCreatePoiEvent.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseCreatePoiEvent(PleaseCreatePoiEvent event) {
    Timber.d("Please create poi");
    Poi poi = event.getPoi();
    poi.setUpdated(true);
    poi.applyChanges(event.getPoiChanges().getTagsMap());
    poi.applyChanges(applyConstraints(poi));
    poiManager.savePoi(poi);
    poiManager.updatePoiTypeLastUse(poi.getType().getId());
    eventBus.post(new PoiChangesApplyEvent());
}
Also used : PoiChangesApplyEvent(io.jawg.osmcontributor.ui.events.edition.PoiChangesApplyEvent) Poi(io.jawg.osmcontributor.model.entities.Poi) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 19 with Poi

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

the class EditPoiManager method onPleaseApplyPoiPositionChange.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseApplyPoiPositionChange(PleaseApplyPoiPositionChange event) {
    Timber.d("Please apply poi position change");
    Poi editPoi = poiManager.queryForId(event.getPoiId());
    editPoi.setOldPoiId(saveOldVersionOfPoi(editPoi));
    editPoi.setLatitude(event.getPoiPosition().getLatitude());
    editPoi.setLongitude(event.getPoiPosition().getLongitude());
    editPoi.setUpdated(true);
    poiManager.savePoi(editPoi);
    poiManager.updatePoiTypeLastUse(editPoi.getType().getId());
}
Also used : Poi(io.jawg.osmcontributor.model.entities.Poi) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 20 with Poi

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

the class EditPoiManager method onPleaseCreateNoTagPoiEvent.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseCreateNoTagPoiEvent(PleaseCreateNoTagPoiEvent event) {
    Poi poi = new Poi();
    LatLng latLng = event.getLatLng();
    poi.setLatitude(latLng.getLatitude());
    poi.setLongitude(latLng.getLongitude());
    poi.setType(event.getPoiType());
    List<PoiTag> defaultTags = new ArrayList<>();
    for (PoiTypeTag poiTypeTag : poi.getType().getTags()) {
        if (poiTypeTag.getValue() != null) {
            // default tags should be set in the corresponding POI
            PoiTag poiTag = new PoiTag();
            poiTag.setKey(poiTypeTag.getKey());
            poiTag.setValue(poiTypeTag.getValue());
            defaultTags.add(poiTag);
        }
    }
    poi.setTags(defaultTags);
    poi.setUpdated(true);
    poiManager.savePoi(poi);
    poiManager.updatePoiTypeLastUse(event.getPoiType().getId());
    eventBus.post(new PoiNoTypeCreated());
}
Also used : PoiTag(io.jawg.osmcontributor.model.entities.PoiTag) PoiNoTypeCreated(io.jawg.osmcontributor.ui.events.map.PoiNoTypeCreated) ArrayList(java.util.ArrayList) Poi(io.jawg.osmcontributor.model.entities.Poi) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) PoiTypeTag(io.jawg.osmcontributor.model.entities.PoiTypeTag) Subscribe(org.greenrobot.eventbus.Subscribe)

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