Package com.airbnb.lottie
Class LottieTask<T>
- java.lang.Object
-
- com.airbnb.lottie.LottieTask<T>
-
public class LottieTask<T> extends Object
Helper to run asynchronous tasks with a result. Results can be obtained withaddListener(LottieListener). Failures can be obtained withaddFailureListener(LottieListener).A task will produce a single result or a single failure.
-
-
Constructor Summary
Constructors Constructor Description LottieTask(Callable<LottieResult<T>> runnable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LottieTask<T>addFailureListener(LottieListener<Throwable> listener)Add a task failure listener.LottieTask<T>addListener(LottieListener<T> listener)Add a task listener.LottieTask<T>removeFailureListener(LottieListener<Throwable> listener)Remove a given task failure listener.LottieTask<T>removeListener(LottieListener<T> listener)Remove a given task listener.
-
-
-
Field Detail
-
EXECUTOR
public static Executor EXECUTOR
Set this to change the executor that LottieTasks are run on. This will be the executor that composition parsing and url fetching happens on.You may change this to run deserialization synchronously for testing.
-
-
Constructor Detail
-
LottieTask
public LottieTask(Callable<LottieResult<T>> runnable)
-
-
Method Detail
-
addListener
public LottieTask<T> addListener(LottieListener<T> listener)
Add a task listener. If the task has completed, the listener will be called synchronously.- Returns:
- the task for call chaining.
-
removeListener
public LottieTask<T> removeListener(LottieListener<T> listener)
Remove a given task listener. The task will continue to execute so you can re-add a listener if necessary.- Returns:
- the task for call chaining.
-
addFailureListener
public LottieTask<T> addFailureListener(LottieListener<Throwable> listener)
Add a task failure listener. This will only be called in the even that an exception occurs. If an exception has already occurred, the listener will be called immediately.- Returns:
- the task for call chaining.
-
removeFailureListener
public LottieTask<T> removeFailureListener(LottieListener<Throwable> listener)
Remove a given task failure listener. The task will continue to execute so you can re-add a listener if necessary.- Returns:
- the task for call chaining.
-
-