
com.path.android.jobqueue.nonPersistentQueue.ConsistentTimedComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-priority-jobqueue Show documentation
Show all versions of android-priority-jobqueue Show documentation
a Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.
package com.path.android.jobqueue.nonPersistentQueue;
import com.path.android.jobqueue.JobHolder;
import java.util.Comparator;
/**
* A job holder comparator that checks time before checking anything else
*/
public class ConsistentTimedComparator implements Comparator {
final Comparator baseComparator;
public ConsistentTimedComparator(Comparator baseComparator) {
this.baseComparator = baseComparator;
}
@Override
public int compare(JobHolder jobHolder, JobHolder jobHolder2) {
if(jobHolder.getDelayUntilNs() < jobHolder2.getDelayUntilNs()) {
return -1;
} else if(jobHolder.getDelayUntilNs() > jobHolder2.getDelayUntilNs()) {
return 1;
}
return baseComparator.compare(jobHolder, jobHolder2);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy