Class CallbackDispatcher<T>

java.lang.Object
com.codename1.util.CallbackDispatcher<T>
All Implemented Interfaces:
Runnable

public final class CallbackDispatcher<T> extends Object implements Runnable
A utility class for calling Callbacks on the EDT.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Calls the given callback's java.lang.Throwable, int, java.lang.String) method, passing the supplied error as a parameter.
    static <T> void
    dispatchSuccess(SuccessCallback<T> success, T arg)
    Calls the given callback's Callback#onSucess(java.lang.Object) method, passing the supplied arg as a parameter.
    void
    run()
    When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Method Details

    • dispatchSuccess

      public static <T> void dispatchSuccess(SuccessCallback<T> success, T arg)

      Calls the given callback's Callback#onSucess(java.lang.Object) method, passing the supplied arg as a parameter. This method guarantees that onSuccess() will be called on the EDT. If it is already running on the EDT, it will just call it directly. Otherwise it will wrap it in Display#callSerially(java.lang.Runnable).

      Parameters
      • The: type of the callback.

      • success: The success callback to be called.

      • arg: The argument to pass to the success callback.

    • dispatchError

      public static void dispatchError(FailureCallback failure, Throwable error)

      Calls the given callback's java.lang.Throwable, int, java.lang.String) method, passing the supplied error as a parameter. This method guarantees that onError() will be called on the EDT. If it is already running on the EDT, it will just call it directly. Otherwise it will wrap it in Display#callSerially(java.lang.Runnable).

      Parameters
      • failure: The failure callback to be called.

      • error: The error to pass to the callback

    • run

      public void run()
      Description copied from interface: Runnable
      When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread. The general contract of the method run is that it may take any action whatsoever.
      Specified by:
      run in interface Runnable