Search in sources :

Example 51 with Subscribe

use of org.greenrobot.eventbus.Subscribe 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 52 with Subscribe

use of org.greenrobot.eventbus.Subscribe 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)

Example 53 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project osm-contributor by jawg.

the class EditPoiManager method onPleaseApplyNodeRefPositionChange.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseApplyNodeRefPositionChange(PleaseApplyNodeRefPositionChange event) {
    Timber.d("Please apply noderef position change");
    LatLng newLatLng = event.getPoiPosition();
    // apply changes on the noderef
    PoiNodeRef poiNodeRef = poiNodeRefDao.queryForId(event.getPoiId());
    poiNodeRef.setOldPoiId(saveOldVersionOfPoiNodeRef(poiNodeRef));
    poiNodeRef.setLongitude(newLatLng.getLongitude());
    poiNodeRef.setLatitude(newLatLng.getLatitude());
    poiNodeRef.setUpdated(true);
    poiNodeRefDao.createOrUpdate(poiNodeRef);
}
Also used : LatLng(com.mapbox.mapboxsdk.geometry.LatLng) PoiNodeRef(io.jawg.osmcontributor.model.entities.PoiNodeRef) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 54 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project osm-contributor by jawg.

the class TypeManager method onInternalUpdatePoiTagsEvent.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onInternalUpdatePoiTagsEvent(InternalUpdatePoiTagsEvent event) {
    PoiType poiType = event.getPoiType();
    poiManager.savePoiType(poiType);
    bus.post(new PoiTagsUpdatedEvent(poiType));
}
Also used : PoiTagsUpdatedEvent(io.jawg.osmcontributor.ui.events.type.PoiTagsUpdatedEvent) PoiType(io.jawg.osmcontributor.model.entities.PoiType) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 55 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project osm-contributor by jawg.

the class TypeManager method onInternalSavePoiTagEvent.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onInternalSavePoiTagEvent(InternalSavePoiTagEvent event) {
    PoiTypeTag poiTypeTag = event.getPoiTypeTag();
    PoiType poiType = poiTypeTag.getPoiType();
    poiManager.savePoiType(poiType);
    bus.post(new PoiTagCreatedEvent(poiTypeTag));
}
Also used : PoiTagCreatedEvent(io.jawg.osmcontributor.ui.events.type.PoiTagCreatedEvent) PoiType(io.jawg.osmcontributor.model.entities.PoiType) PoiTypeTag(io.jawg.osmcontributor.model.entities.PoiTypeTag) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

Subscribe (org.greenrobot.eventbus.Subscribe)164 Intent (android.content.Intent)20 Bundle (android.os.Bundle)11 EventBus (org.greenrobot.eventbus.EventBus)10 ThreadMode (org.greenrobot.eventbus.ThreadMode)10 View (android.view.View)9 Poi (io.jawg.osmcontributor.model.entities.Poi)9 PoiType (io.jawg.osmcontributor.model.entities.PoiType)9 ArrayList (java.util.ArrayList)9 Context (android.content.Context)8 Handler (android.os.Handler)8 ViewGroup (android.view.ViewGroup)8 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)8 SuppressLint (android.annotation.SuppressLint)6 LayoutInflater (android.view.LayoutInflater)6 MenuItem (android.view.MenuItem)6 DownloaderUpdate (de.danoeh.antennapod.core.event.DownloaderUpdate)6 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)6 Disposable (io.reactivex.disposables.Disposable)6 Schedulers (io.reactivex.schedulers.Schedulers)6