org.androidannotations.api
Class BackgroundExecutor

java.lang.Object
  extended by org.androidannotations.api.BackgroundExecutor

public class BackgroundExecutor
extends Object


Nested Class Summary
static class BackgroundExecutor.Task
           
 
Field Summary
static Executor DEFAULT_EXECUTOR
           
 
Constructor Summary
BackgroundExecutor()
           
 
Method Summary
static void cancelAll(String id, boolean mayInterruptIfRunning)
          Cancel all tasks having the specified id.
static void execute(BackgroundExecutor.Task task)
          Execute a task after (at least) its delay and after all tasks added with the same non-null serial (if any) have completed execution.
static void execute(Runnable runnable)
          Execute a task.
static void execute(Runnable runnable, int delay)
          Execute a task after the given delay.
static void execute(Runnable runnable, String id, int delay, String serial)
          Execute a task.
static void execute(Runnable runnable, String id, String serial)
          Execute a task after all tasks added with the same non-null serial (if any) have completed execution.
static void setExecutor(Executor executor)
          Change the executor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EXECUTOR

public static Executor DEFAULT_EXECUTOR
Constructor Detail

BackgroundExecutor

public BackgroundExecutor()
Method Detail

execute

public static void execute(BackgroundExecutor.Task task)
Execute a task after (at least) its delay and after all tasks added with the same non-null serial (if any) have completed execution.

Parameters:
task - the task to execute
Throws:
IllegalArgumentException - if task.delay is strictly positive and the current executor does not support scheduling (if setExecutor(Executor) has been called with such an executor)

execute

public static void execute(Runnable runnable,
                           String id,
                           int delay,
                           String serial)
Execute a task.

Parameters:
runnable - the task to execute
id - identifier used for task cancellation
delay - the time from now to delay execution, in milliseconds
serial - the serial queue (null or "" for no serial execution)
Throws:
IllegalArgumentException - if delay is strictly positive and the current executor does not support scheduling (if setExecutor(Executor) has been called with such an executor)

execute

public static void execute(Runnable runnable,
                           int delay)
Execute a task after the given delay.

Parameters:
runnable - the task to execute
delay - the time from now to delay execution, in milliseconds
Throws:
IllegalArgumentException - if delay is strictly positive and the current executor does not support scheduling (if setExecutor(Executor) has been called with such an executor)

execute

public static void execute(Runnable runnable)
Execute a task.

Parameters:
runnable - the task to execute

execute

public static void execute(Runnable runnable,
                           String id,
                           String serial)
Execute a task after all tasks added with the same non-null serial (if any) have completed execution. Equivalent to execute(runnable, id, 0, serial).

Parameters:
runnable - the task to execute
id - identifier used for task cancellation
serial - the serial queue to use (null or "" for no serial execution)

setExecutor

public static void setExecutor(Executor executor)
Change the executor. Note that if the given executor is not a ScheduledExecutorService then executing a task after a delay will not be supported anymore. If it is not even a ExecutorService then tasks will not be cancellable anymore.

Parameters:
executor - the new executor

cancelAll

public static void cancelAll(String id,
                             boolean mayInterruptIfRunning)
Cancel all tasks having the specified id.

Parameters:
id - the cancellation identifier
mayInterruptIfRunning - true if the thread executing this task should be interrupted; otherwise, in-progress tasks are allowed to complete


Copyright © 2010-2014. All Rights Reserved.