本文整理匯總了Java中com.github.czyzby.autumn.annotation.OnEvent.REMOVE屬性的典型用法代碼示例。如果您正苦於以下問題:Java OnEvent.REMOVE屬性的具體用法?Java OnEvent.REMOVE怎麽用?Java OnEvent.REMOVE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.github.czyzby.autumn.annotation.OnEvent
的用法示例。
在下文中一共展示了OnEvent.REMOVE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onEvent
@OnEvent(VersionUpdateCheckEvent.class) boolean onEvent(VersionUpdateCheckEvent event) {
switch (event.getAction()) {
case CHECK_STARTED:
case CHECK_FINISHED:
return OnEvent.KEEP;
case FINISHED_ERROR:
case FINISHED_UP_TO_DATE:
return OnEvent.REMOVE;
case FINISHED_UPDATE_AVAILABLE:
// toastManager.show
return OnEvent.REMOVE;
default:
// Should never happen
throw new IllegalStateException("Unexpected version check event: " + event.getAction());
}
}
示例2: processEvent
@Override
public boolean processEvent(final Object event) {
replaceParameters(event);
try {
final Object result = invoke();
if (removeAfterInvocation) {
return OnEvent.REMOVE;
} else if (result instanceof Boolean) {
return ((Boolean) result).booleanValue();
}
return OnEvent.KEEP;
} catch (final Exception exception) {
if (strict) {
// Gdx applications seem to ignore exceptions in posted runnables. This is bad.
Gdx.app.error("ERROR", "Exception occured on event listener.", exception);
throw new GdxRuntimeException("Unable to invoke event listener.", exception);
}
return OnEvent.KEEP;
}
}
示例3: processMessage
@Override
public boolean processMessage() {
replaceParameters();
try {
final Object result = invoke();
if (removeAfterInvocation) {
return OnEvent.REMOVE;
} else if (result instanceof Boolean) {
return ((Boolean) result).booleanValue();
}
return OnEvent.KEEP;
} catch (final Exception exception) {
if (strict) {
// Gdx applications seem to ignore exceptions in posted runnables. This is bad.
Gdx.app.error("ERROR", "Exception occured on message listener.", exception);
throw new GdxRuntimeException("Unable to invoke message listener.", exception);
}
return OnEvent.KEEP;
}
}
示例4: onEvent
@OnEvent(VersionUpdateCheckEvent.class) boolean onEvent(VersionUpdateCheckEvent event) {
switch (event.getAction()) {
case FINISHED_ERROR:
case FINISHED_UP_TO_DATE:
// Everything appears to be fine, stop listening for updates
return OnEvent.REMOVE;
case FINISHED_UPDATE_AVAILABLE:
showUpdateNotification(event.getLatestVersion());
return OnEvent.REMOVE;
}
return OnEvent.KEEP;
}
示例5: onEvent
/** Will be invoked any time {@link MyEvent} instance is posted using {@link EventDispatcher}. Note that annotated
* listener methods can contain any injectable parameters, using the same mechanism as {@link Inject} or
* {@link Initiate} annotations, as well as {@link MyEvent} parameter.
* <p>
* By returning a boolean result, you can decide whether the event listener should be kept or removed. This allows
* you to easily removed no longer needed listeners. (Note that same applies to OnMessage methods.)
*
* @param event will be injected.
* @return see {@link OnEvent#KEEP} and {@link OnEvent#REMOVE}. */
@OnEvent(MyEvent.class)
public boolean onEvent(final MyEvent event) {
LOGGER.info("I detected a MyEvent: {0}. Removing this listener.", event.getMessage());
return OnEvent.REMOVE;
}