kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add the ability to get the current state of a job.
rodzic
1f860d41b5
commit
51c86cab10
|
@ -137,6 +137,14 @@ public class JobManager implements ConstraintObserver.Notifier {
|
||||||
jobTracker.removeListener(listener);
|
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.
|
* Enqueues a single job to be run.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.thoughtcrime.securesms.util.LRUCache;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.
|
* Update the state of a job with the associated ID.
|
||||||
*/
|
*/
|
||||||
|
|
Ładowanie…
Reference in New Issue