Search in sources :

Example 56 with Subscribe

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

the class TypeManager method onInternalRemovePoiTypeEvent.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onInternalRemovePoiTypeEvent(InternalRemovePoiTypeEvent event) {
    PoiType poiType = event.getPoiType();
    poiManager.deletePoiType(poiType);
    Timber.i("Removed poi type %d", poiType.getId());
    bus.post(new PoiTypeDeletedEvent(poiType));
    bus.post(new PoiTypesLoaded(poiManager.getPoiTypesSortedByName()));
}
Also used : PoiTypeDeletedEvent(io.jawg.osmcontributor.ui.events.type.PoiTypeDeletedEvent) PoiType(io.jawg.osmcontributor.model.entities.PoiType) PoiTypesLoaded(io.jawg.osmcontributor.model.events.PoiTypesLoaded) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 57 with Subscribe

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

the class TypeListActivityPresenter method onInternalTypesLoadedEvent.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onInternalTypesLoadedEvent(InternalTypesLoadedEvent event) {
    List<PoiType> currentPoiTypes = event.getPoiTypes();
    PoiType currentPoiType = event.getCurrentPoiType();
    if (currentPoiType == null) {
        typeListActivity.showTypes(currentPoiTypes);
    } else {
        typeListActivity.showTags(currentPoiType.getTags(), currentPoiType);
    }
    this.currentPoiType = currentPoiType;
}
Also used : PoiType(io.jawg.osmcontributor.model.entities.PoiType) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 58 with Subscribe

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

the class TypeListActivityPresenter method onInternalPleaseLoadEvent.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onInternalPleaseLoadEvent(InternalPleaseLoadEvent event) {
    List<PoiType> poiTypesAlphabeticallySorted = poiManager.getPoiTypesSortedByName();
    for (PoiType type : poiTypesAlphabeticallySorted) {
        type.setTags(DatabaseHelper.loadLazyForeignCollection(type.getTags()));
    }
    PoiType currentPoiType = null;
    Long currentPoiTypeId = event.getCurrentPoiTypeId();
    if (currentPoiTypeId != null) {
        for (PoiType type : poiTypesAlphabeticallySorted) {
            if (currentPoiTypeId.equals(type.getId())) {
                currentPoiType = type;
                break;
            }
        }
        if (currentPoiType == null) {
            throw new IllegalStateException("Current POI type not found after reloading data");
        }
    }
    bus.post(new InternalTypesLoadedEvent(poiTypesAlphabeticallySorted, currentPoiType));
}
Also used : PoiType(io.jawg.osmcontributor.model.entities.PoiType) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 59 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project anitrend-app by AniTrend.

the class ComposerWidget method onEmojiClicked.

@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
public void onEmojiClicked(Emoji emoji) {
    EditText editor = binding.comment;
    int start = editor.getSelectionStart();
    editor.getEditableText().insert(start, emoji.getEmoji());
}
Also used : EditText(android.widget.EditText) SuppressLint(android.annotation.SuppressLint) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 60 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project EventBus by greenrobot.

the class EventBusAnnotationProcessor method writeCreateSubscriberMethods.

private void writeCreateSubscriberMethods(BufferedWriter writer, List<ExecutableElement> methods, String callPrefix, String myPackage) throws IOException {
    for (ExecutableElement method : methods) {
        List<? extends VariableElement> parameters = method.getParameters();
        TypeMirror paramType = getParamTypeMirror(parameters.get(0), null);
        TypeElement paramElement = (TypeElement) processingEnv.getTypeUtils().asElement(paramType);
        String methodName = method.getSimpleName().toString();
        String eventClass = getClassString(paramElement, myPackage) + ".class";
        Subscribe subscribe = method.getAnnotation(Subscribe.class);
        List<String> parts = new ArrayList<>();
        parts.add(callPrefix + "(\"" + methodName + "\",");
        String lineEnd = "),";
        if (subscribe.priority() == 0 && !subscribe.sticky()) {
            if (subscribe.threadMode() == ThreadMode.POSTING) {
                parts.add(eventClass + lineEnd);
            } else {
                parts.add(eventClass + ",");
                parts.add("ThreadMode." + subscribe.threadMode().name() + lineEnd);
            }
        } else {
            parts.add(eventClass + ",");
            parts.add("ThreadMode." + subscribe.threadMode().name() + ",");
            parts.add(subscribe.priority() + ",");
            parts.add(subscribe.sticky() + lineEnd);
        }
        writeLine(writer, 3, parts.toArray(new String[parts.size()]));
        if (verbose) {
            processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Indexed @Subscribe at " + method.getEnclosingElement().getSimpleName() + "." + methodName + "(" + paramElement.getSimpleName() + ")");
        }
    }
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) ArrayList(java.util.ArrayList) 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