Add the ability to get the current state of a job.
This commit is contained in:
parent
1f860d41b5
commit
51c86cab10
2 changed files with 21 additions and 1 deletions
|
@ -137,6 +137,14 @@ public class JobManager implements ConstraintObserver.Notifier {
|
|||
jobTracker.removeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the first Job that matches the provided filter. Note that there will always be races here, and the result you get back may not be
|
||||
* valid anymore by the time you get it. Use with caution.
|
||||
*/
|
||||
public @Nullable JobTracker.JobState getFirstMatchingJobState(@NonNull JobTracker.JobFilter filter) {
|
||||
return jobTracker.getFirstMatchingJobState(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues a single job to be run.
|
||||
*/
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.thoughtcrime.securesms.util.LRUCache;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -54,6 +53,19 @@ public class JobTracker {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the first Job that matches the provided filter. Note that there will always be races here, and the result you get back may not be
|
||||
* valid anymore by the time you get it. Use with caution.
|
||||
*/
|
||||
synchronized @Nullable JobState getFirstMatchingJobState(@NonNull JobFilter filter) {
|
||||
for (JobInfo info : jobInfos.values()) {
|
||||
if (filter.matches(info.getJob())) {
|
||||
return info.getJobState();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the state of a job with the associated ID.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue