Class KriptonTaskExecutor

java.lang.Object
com.abubusoft.kripton.android.executor.TaskExecutor
com.abubusoft.kripton.android.executor.KriptonTaskExecutor

public class KriptonTaskExecutor
extends TaskExecutor
A static class that serves as a central point to execute common tasks.
  • Method Summary

    Modifier and Type Method Description
    void executeOnDiskIO​(java.lang.Runnable runnable)
    Executes the given task in the disk IO thread pool.
    static KriptonTaskExecutor getInstance()
    Returns an instance of the task executor.
    static java.util.concurrent.Executor getIOThreadExecutor()
    Gets the IO thread executor.
    static java.util.concurrent.Executor getMainThreadExecutor()
    Gets the main thread executor.
    boolean isMainThread()
    Returns true if the current thread is the main thread, false otherwise.
    void postToMainThread​(java.lang.Runnable runnable)
    Posts the given task to the main thread.
    void setDelegate​(TaskExecutor taskExecutor)
    Sets a delegate to handle task execution requests.

    Methods inherited from class com.abubusoft.kripton.android.executor.TaskExecutor

    executeOnMainThread

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getInstance

      public static KriptonTaskExecutor getInstance()
      Returns an instance of the task executor.
      Returns:
      The singleton ArchTaskExecutor.
    • setDelegate

      public void setDelegate​(TaskExecutor taskExecutor)
      Sets a delegate to handle task execution requests.

      If you have a common executor, you can set it as the delegate and App Toolkit components will use your executors. You may also want to use this for your tests.

      Calling this method with null sets it to the default TaskExecutor.

      Parameters:
      taskExecutor - The task executor to handle task requests.
    • executeOnDiskIO

      public void executeOnDiskIO​(java.lang.Runnable runnable)
      Description copied from class: TaskExecutor
      Executes the given task in the disk IO thread pool.
      Specified by:
      executeOnDiskIO in class TaskExecutor
      Parameters:
      runnable - The runnable to run in the disk IO thread pool.
    • postToMainThread

      public void postToMainThread​(java.lang.Runnable runnable)
      Description copied from class: TaskExecutor
      Posts the given task to the main thread.
      Specified by:
      postToMainThread in class TaskExecutor
      Parameters:
      runnable - The runnable to run on the main thread.
    • getMainThreadExecutor

      public static java.util.concurrent.Executor getMainThreadExecutor()
      Gets the main thread executor.
      Returns:
      the main thread executor
    • getIOThreadExecutor

      public static java.util.concurrent.Executor getIOThreadExecutor()
      Gets the IO thread executor.
      Returns:
      the IO thread executor
    • isMainThread

      public boolean isMainThread()
      Description copied from class: TaskExecutor
      Returns true if the current thread is the main thread, false otherwise.
      Specified by:
      isMainThread in class TaskExecutor
      Returns:
      true if we are on the main thread, false otherwise.