public class

JobScheduler

extends Object
java.lang.Object
   ↳ com.facebook.imagepipeline.producers.JobScheduler

Class Overview

Manages jobs so that only one can be executed at a time and no more often than once in mMinimumJobIntervalMs milliseconds.

Summary

Nested Classes
interface JobScheduler.JobRunnable  
Public Constructors
JobScheduler(Executor executor, JobScheduler.JobRunnable jobRunnable, int minimumJobIntervalMs)
Public Methods
void clearJob()
Clears the currently set job.
synchronized long getQueuedTime()
Gets the queued time in milliseconds for the currently running job.
boolean scheduleJob()
Schedules the currently set job (if any).
boolean updateJob(EncodedImage encodedImage, int status)
Updates the job.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public JobScheduler (Executor executor, JobScheduler.JobRunnable jobRunnable, int minimumJobIntervalMs)

Public Methods

public void clearJob ()

Clears the currently set job.

In case the currently set job has been scheduled but not started yet, the job won't be executed.

public synchronized long getQueuedTime ()

Gets the queued time in milliseconds for the currently running job.

The result is only valid if called from run(EncodedImage, int).

public boolean scheduleJob ()

Schedules the currently set job (if any).

This method can be called multiple times. It is guaranteed that each job set will be executed no more than once. It is guaranteed that the last job set will be executed, unless the job was cleared first.

The job will be scheduled no sooner than minimumJobIntervalMs milliseconds since the last job started.

Returns
  • true if the job was scheduled, false if there was no valid job to be scheduled

public boolean updateJob (EncodedImage encodedImage, int status)

Updates the job.

This just updates the job, but it doesn't schedule it. In order to be executed, the job has to be scheduled after being set. In case there was a previous job scheduled that has not yet started, this new job will be executed instead.

Returns
  • whether the job was successfully updated.