Class AbstractScheduledTask

  • All Implemented Interfaces:
    ScheduledTask

    public abstract class AbstractScheduledTask
    extends Object
    implements ScheduledTask
    Base scheduled task class with default implementations.
    • Constructor Detail

      • AbstractScheduledTask

        public AbstractScheduledTask()
    • Method Detail

      • getTaskData

        public String getTaskData()
        Description copied from interface: ScheduledTask
        Returns the task data that is needed to build a copy of this task instance. It could be a JSON string and it could also be null. See the discussion at TaskScheduler for the cases when this data string is used.
        Specified by:
        getTaskData in interface ScheduledTask
        Returns:
        the task data
      • setTaskData

        public void setTaskData​(String taskData)
                         throws ParseException
        Description copied from interface: ScheduledTask
        The TaskScheduler may call this method when it needs to build a copy of an instance that was passed earlier. In that case it will construct an instance with the default constructor and then call this method. The specified data string was obtained from getTaskData(). It could be a JSON string and it could also be null. See the discussion at TaskScheduler for the cases when this is used.
        Specified by:
        setTaskData in interface ScheduledTask
        Parameters:
        taskData - the task data
        Throws:
        ParseException - if the data string can't be parsed
      • getSchedule

        public TaskSchedule getSchedule()
        Description copied from interface: ScheduledTask
        Returns the schedule at which the task should be run.
        Specified by:
        getSchedule in interface ScheduledTask
        Returns:
        the schedule at which the task should be run
      • setSchedule

        public void setSchedule​(TaskSchedule schedule)
        Sets the schedule at which the task should be run. The default is TaskSchedule.Immediate.
        Parameters:
        schedule - the schedule at which the task should be run
      • isRunOnWorkerThread

        public boolean isRunOnWorkerThread()
        Description copied from interface: ScheduledTask
        Returns whether the task should run on a worker thread or on the UI thread in Android. In standard Java this is ignored and a task is always run on a worker thread.
        Specified by:
        isRunOnWorkerThread in interface ScheduledTask
        Returns:
        true if the task should run on a worker thread, false if it should run on the UI thread
      • setRunOnWorkerThread

        public void setRunOnWorkerThread​(boolean runOnWorkerThread)
        Sets whether the task should run on a worker thread or on the scheduling thread (the UI thread in Android). The default is false.
        Parameters:
        runOnWorkerThread - true if the task should run on a worker thread, false if it should run on the scheduling thread
      • cancel

        public void cancel​(Object context)
        Description copied from interface: ScheduledTask
        Cancels the task. This is called by the TaskScheduler if the task was started and should be cancelled. In Android this method is called on the UI thread.
        Specified by:
        cancel in interface ScheduledTask
        Parameters:
        context - the context (only set in Android)