|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.path.android.jobqueue.JobManager
public class JobManager
a JobManager that supports; -> Persistent / Non Persistent Jobs -> Job Priority -> Running Jobs in Parallel -> Grouping jobs so that they won't run at the same time -> Stats like waiting Job Count
Nested Class Summary | |
---|---|
static class |
JobManager.DefaultQueueFactory
Default implementation of QueueFactory that creates one SqliteJobQueue and one NonPersistentPriorityQueue
both are wrapped inside a CachedJobQueue to improve performance |
Field Summary | |
---|---|
static long |
NOT_DELAYED_JOB_DELAY
|
static long |
NOT_RUNNING_SESSION_ID
|
static long |
NS_PER_MS
|
Constructor Summary | |
---|---|
JobManager(Context context)
Default constructor that will create a JobManager with 1 SqliteJobQueue and 1 NonPersistentPriorityQueue |
|
JobManager(Context context,
Configuration config)
|
|
JobManager(Context context,
java.lang.String id)
Default constructor that will create a JobManager with a default Configuration |
Method Summary | |
---|---|
long |
addJob(int priority,
BaseJob baseJob)
Deprecated. |
long |
addJob(int priority,
long delay,
BaseJob baseJob)
Deprecated. |
long |
addJob(Job job)
Adds a new Job to the list and returns an ID for it. |
void |
addJobInBackground(int priority,
BaseJob baseJob)
Deprecated. |
void |
addJobInBackground(int priority,
long delay,
BaseJob baseJob)
Deprecated. |
protected void |
addJobInBackground(int priority,
long delay,
BaseJob baseJob,
AsyncAddCallback callback)
|
void |
addJobInBackground(Job job)
Non-blocking convenience method to add a job in background thread. |
void |
addJobInBackground(Job job,
AsyncAddCallback callback)
|
void |
clear()
|
int |
count()
returns the # of jobs that are waiting to be executed. |
JobStatus |
getJobStatus(long id,
boolean isPersistent)
Returns the current status of a Job . |
void |
onNetworkChange(boolean isConnected)
if NetworkUtil implements NetworkEventProvider , this method is called when network is recovered |
void |
start()
restarts the JobManager. |
void |
stop()
Stops consuming jobs. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long NS_PER_MS
public static final long NOT_RUNNING_SESSION_ID
public static final long NOT_DELAYED_JOB_DELAY
Constructor Detail |
---|
public JobManager(Context context)
SqliteJobQueue
and 1 NonPersistentPriorityQueue
context
- job manager will use applicationContext.public JobManager(Context context, java.lang.String id)
Configuration
context
- application contextid
- an id that is unique to this JobManagerpublic JobManager(Context context, Configuration config)
context
- used to acquire ApplicationContextconfig
- Method Detail |
---|
public void stop()
public void start()
public int count()
public long addJob(Job job)
job
- to add
public void addJobInBackground(Job job)
job
- job to addaddJob(Job)
public void addJobInBackground(Job job, AsyncAddCallback callback)
public JobStatus getJobStatus(long id, boolean isPersistent)
Job
.
You should not call this method on the UI thread because it may make a db request.
This is not a very fast call so try not to make it unless necessary. Consider using events if you need to be informed about a job's lifecycle.
id
- the ID, returned by the addJob methodisPersistent
- Jobs are added to different queues depending on if they are persistent or not. This is necessary
because each queue has independent id sets.
public void clear()
public void onNetworkChange(boolean isConnected)
NetworkUtil
implements NetworkEventProvider
, this method is called when network is recovered
onNetworkChange
in interface NetworkEventProvider.Listener
isConnected
- network connection state.@Deprecated public long addJob(int priority, BaseJob baseJob)
addJob(Job)
.
Adds a job with given priority and returns the JobId.
priority
- Higher runs firstbaseJob
- The actual job to run
@Deprecated public long addJob(int priority, long delay, BaseJob baseJob)
addJob(Job)
.
Adds a job with given priority and returns the JobId.
priority
- Higher runs firstdelay
- number of milliseconds that this job should be delayedbaseJob
- The actual job to run
@Deprecated public void addJobInBackground(int priority, BaseJob baseJob)
addJobInBackground(Job)
.
Non-blocking convenience method to add a job in background thread.
addJob(priority, job).
@Deprecated public void addJobInBackground(int priority, long delay, BaseJob baseJob)
addJobInBackground(Job)
.
Non-blocking convenience method to add a job in background thread.
addJob(priority, delay, job).
protected void addJobInBackground(int priority, long delay, BaseJob baseJob, AsyncAddCallback callback)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |