Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keeping track of jobs #245

Open
miomao656 opened this issue Sep 3, 2016 · 3 comments
Open

Keeping track of jobs #245

miomao656 opened this issue Sep 3, 2016 · 3 comments

Comments

@miomao656
Copy link

Hi,

First thanks for this great library! :)

I have an issue when adding jobs from widgets like recycler view on bind view i need to know if job for that view is already added. This is an issue due to the fact that anytime you scroll down the list it will add job from item again and again and call onCanceled in job.
Does the library keep a reference to jobs in queue somewhere and how can i implement this if possible?
This is needed to avoid adding same jobs again and again and restarting or canceling job in progress that way.

@yigit
Copy link
Owner

yigit commented Sep 4, 2016

Creating a job from RV's onBind may not be a great idea (because it will happen a lot) but you can use singleInstanceBy parameter in the Job so that JobManager will keep only 1 instance of the job at a given time. Make sure you use addJobInBackground while adding the job.

@miomao656
Copy link
Author

Yes i am creating and adding jobs just as how you suggested. So there is no way to retrieve list of jobs from the library so that i can compare if they are already added?

@yigit
Copy link
Owner

yigit commented Sep 11, 2016

There is a getJobStatus API but you cannot call it on the main thread because it will possibly wait for a lock on queues depending on JobManager's state.
FYI, It cannot distinguish between a Job that has never been added and a job that has finished.

http://yigit.github.io/android-priority-jobqueue/javadoc/com/birbit/android/jobqueue/JobManager.html#getJobStatus-java.lang.String-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants