|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Retention(value=CLASS) @Target(value=METHOD) public @interface UiThread
Should be used on method that must be run in the Ui thread
The annotated method MUST return void and MAY contain parameters. The generated code is based on a localHandler
instance.
delay()
field.
Example :@EBean public class MyBean { @UiThread(delay = 2000) void uiThreadTask() { // ... } }
UiThread
annotated method calls was always added in the
handler execution queue to ensure that execution was done in Ui thread. In
3.0, we kept the same behavior for compatibility purpose.
But, if you want to optimize UiThread calls, you may want to change
propagation()
value to REUSE
. In this configuration,
the code will make a direct call to the method if current thread is already
Ui thread. If not, we're falling back to handler call.
Example :@EBean public class MyBean { @UiThread void uiThreadTask() { // This code is executed via the handler // The following method will be directly executed instead of using // handler uiThreadTaskReused(); } @UiThread(propagation = REUSE) void uiThreadTaskReused() { // ... } }
Background
,
Handler
Optional Element Summary | |
---|---|
long |
delay
|
UiThread.Propagation |
propagation
If propagation = REUSE, the method will check first if it is inside the UI thread already. |
public abstract long delay
public abstract UiThread.Propagation propagation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |