Package page.codeberg.friedolyn.util
Class Task.TaskListener<ResultType>
java.lang.Object
page.codeberg.friedolyn.util.Task.TaskListener<ResultType>
- Type Parameters:
ResultType- The class of the end product that the action executed generates.
- All Implemented Interfaces:
Task.CancelListener,Task.FailureListener<ResultType>,Task.ProgressListener,Task.SuccessListener<ResultType>
- Enclosing class:
Task<ResultType>
public abstract static class Task.TaskListener<ResultType>
extends Object
implements Task.ProgressListener, Task.SuccessListener<ResultType>, Task.FailureListener<ResultType>, Task.CancelListener
A subscriber that is interested in status updates of the action's progress.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <ResultType>
@NonNull Task.TaskListener<ResultType> from(@NonNull Task.CancelListener cancelListener) Converts aTask.CancelListenerto aTask.TaskListener.static <ResultType>
@NonNull Task.TaskListener<ResultType> from(@NonNull Task.FailureListener<ResultType> failureListener) Converts aTask.FailureListenerto aTask.TaskListener.static <ResultType>
@NonNull Task.TaskListener<ResultType> from(@NonNull Task.ProgressListener progressListener) Converts aTask.ProgressListenerto aTask.TaskListener.static <ResultType>
@NonNull Task.TaskListener<ResultType> from(@NonNull Task.SuccessListener<ResultType> successListener) Converts aTask.SuccessListenerto aTask.TaskListener.abstract voidCalled when execution of the action has begun.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface page.codeberg.friedolyn.util.Task.CancelListener
onCancelledMethods inherited from interface page.codeberg.friedolyn.util.Task.FailureListener
onFailedMethods inherited from interface page.codeberg.friedolyn.util.Task.ProgressListener
onProgressUpdateMethods inherited from interface page.codeberg.friedolyn.util.Task.SuccessListener
onSucceeded
-
Constructor Details
-
TaskListener
public TaskListener()
-
-
Method Details
-
onStarted
public abstract void onStarted()Called when execution of the action has begun. -
from
@NonNull public static <ResultType> @NonNull Task.TaskListener<ResultType> from(@NonNull @NonNull Task.ProgressListener progressListener) Converts aTask.ProgressListenerto aTask.TaskListener. Useful if only progress updates are needed and no other information.- Type Parameters:
ResultType- The class of the result that the action executed produces.- Parameters:
progressListener- What to do when progress has been made executing the task. Will be called byTask.ProgressListener.onProgressUpdate(int, int).- Returns:
- A
Task.TaskListenerthat calls the givenTask.ProgressListenerwhen progress is made. - See Also:
-
from
@NonNull public static <ResultType> @NonNull Task.TaskListener<ResultType> from(@NonNull @NonNull Task.SuccessListener<ResultType> successListener) Converts aTask.SuccessListenerto aTask.TaskListener. Useful if only the result is needed and no other information.- Type Parameters:
ResultType- The class of the result that the action executed produces.- Parameters:
successListener- What to do when the action has succeeded. Will be called byTask.SuccessListener.onSucceeded(Object).- Returns:
- A
Task.TaskListenerthat calls the givenTask.SuccessListenerwhen the action has succeeded.
-
from
@NonNull public static <ResultType> @NonNull Task.TaskListener<ResultType> from(@NonNull @NonNull Task.FailureListener<ResultType> failureListener) Converts aTask.FailureListenerto aTask.TaskListener. Useful if only the result is needed and no other information.- Type Parameters:
ResultType- The class of the result that the action executed produces.- Parameters:
failureListener- What to do when the action has failed. Will be called byTask.FailureListener.onFailed(Optional).- Returns:
- A
Task.TaskListenerthat calls the givenTask.FailureListenerwhen the action has failed.
-
from
@NonNull public static <ResultType> @NonNull Task.TaskListener<ResultType> from(@NonNull @NonNull Task.CancelListener cancelListener) Converts aTask.CancelListenerto aTask.TaskListener. Useful if only the result is needed and no other information.- Type Parameters:
ResultType- The class of the result that the action executed produces.- Parameters:
cancelListener- What to do when the action has been cancelled. Will be called byTask.CancelListener.onCancelled().- Returns:
- A
Task.TaskListenerthat calls the givenTask.CancelListenerwhen the action has been cancelled.
-