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();
}
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);
}
}
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());
}
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());
}
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());
}
Aggregations