Search in sources :

Example 1 with PoiChangesApplyEvent

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

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

the class EditPoiManager method onPleaseApplyPoiChanges.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseApplyPoiChanges(PleaseApplyPoiChanges event) {
    Timber.d("please apply poi changes");
    Poi editPoi = poiManager.queryForId(event.getPoiChanges().getId());
    if (editPoi.hasChanges(event.getPoiChanges().getTagsMap())) {
        editPoi.setOldPoiId(saveOldVersionOfPoi(editPoi));
        // this is the edition of a new poi or we already edited this poi
        editPoi.applyChanges(event.getPoiChanges().getTagsMap());
        editPoi.applyChanges(applyConstraints(editPoi));
        editPoi.setUpdated(true);
        poiManager.savePoi(editPoi);
        poiManager.updatePoiTypeLastUse(editPoi.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)

Aggregations

Poi (io.jawg.osmcontributor.model.entities.Poi)2 PoiChangesApplyEvent (io.jawg.osmcontributor.ui.events.edition.PoiChangesApplyEvent)2 Subscribe (org.greenrobot.eventbus.Subscribe)2