Closed isabsent closed 6 years ago
The problem was solved. The library works fine. I have made a mistake extending Job. A correct extending is below:.
public abstract public class BaseJob extends Job {
private static final int RETRY_LIMIT = 3;
public static final int UI_HIGH = 10;
public static final int BACKGROUND = 1;
@Retention(RetentionPolicy.SOURCE)
@IntDef({UI_HIGH, BACKGROUND})
public @interface Priority {
}
public BaseJob(Params params) {
super(params);
}
...
}
public abstract class BaseNewsJob extends BaseJob {
public BaseNewsJob() {
super(new Params(BACKGROUND).groupBy(Groups.MAIN_CONTENT));
}
public BaseNewsJob(String... jobTags) {
super(new Params(BACKGROUND).groupBy(Groups.MAIN_CONTENT).addTags(jobTags));
}
...
}
public class GetNewsJob extends BaseNewsJob {
public static final String JOB_TAG = "NEWS_JOB_TAG";
public GetNewsJob(NewsController mNewsController, boolean force) {
super(JOB_TAG);
}
...
}
I call
jobManager.cancelJobs(TagConstraint.ANY, NetRequestJob.JOB_TAG)
in UI thread an control how does it work in the job background thread:isCancelled()
is alwaysfalse
. Am I trying to cancel job by a correct way? If not what should I do to cancel it? Usage ofjobManager.cancelJobsInBackground(null, TagConstraint.ANY, jobTag)
does not change a situation. I have attached demo project which demonstrates the problem - cancellation-fault-demo.zip. When you click on a FAB button job will cancelled, but a breakpoint underwill never reached. Migration to 2.0.1 didn't helped me too.
Other classes are: