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