Skip to content

Commit 32db6fa

Browse files
committed
Remove deprecated BaseJob
Add onCancel guarantee for jobs canceled by the user. Previous, job was removed from disk instantly and if app termniates before onCancel is called, job would not get a chance to clean after itself. This CL also adds a test mode to job manager configuration to use in memory database for persistent queue.
1 parent eed9d0c commit 32db6fa

31 files changed

+673
-376
lines changed

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Although not required, it is most useful when used with an event bus. It also su
4141

4242
Since a code example is worth thousands of documentation pages, here it is.
4343

44-
File: [PostTweetJob.java](https://github.com/path/android-priority-jobqueue/blob/master/examples/twitter/TwitterClient/src/com/path/android/jobqueue/examples/twitter/jobs/PostTweetJob.java)
44+
File: [PostTweetJob.java](https://github.com/yigit/android-priority-jobqueue/blob/master/examples/twitter/TwitterClient/src/com/path/android/jobqueue/examples/twitter/jobs/PostTweetJob.java)
4545
``` java
4646
// A job to send a tweet
4747
public class PostTweetJob extends Job {
@@ -77,7 +77,7 @@ public class PostTweetJob extends Job {
7777

7878
```
7979

80-
File: [TweetActivity.java](https://github.com/path/android-priority-jobqueue/blob/master/examples/twitter/TwitterClient/src/com/path/android/jobqueue/examples/twitter/SampleTwitterClient.java#L53)
80+
File: [TweetActivity.java](https://github.com/yigit/android-priority-jobqueue/blob/master/examples/twitter/TwitterClient/src/com/path/android/jobqueue/examples/twitter/SampleTwitterClient.java#L53)
8181
``` java
8282
//...
8383
public void onSendClick() {
@@ -129,15 +129,15 @@ At Path, we use [greenrobot's EventBus](https://github.com/greenrobot/EventBus);
129129
### Getting Started
130130
We distribute artifacts through maven central repository.
131131

132-
Gradle: `compile 'com.path:android-priority-jobqueue:1.1.2'`
132+
Gradle: `compile 'com.birbit:android-priority-jobqueue:1.1.3'`
133133

134134
Maven:
135135

136136
``` xml
137137
<dependency>
138-
<groupId>com.path</groupId>
138+
<groupId>com.birbit</groupId>
139139
<artifactId>android-priority-jobqueue</artifactId>
140-
<version>1.1.2</version>
140+
<version>1.1.3</version>
141141
</dependency>
142142
```
143143

@@ -150,6 +150,10 @@ We highly recommend checking how you can configure job manager and individual jo
150150
* [Review sample configuration][7]
151151

152152
### Version History
153+
- 1.1.3 (March 21, 2015)
154+
- Ability to add tags to jobs. These tags can be used to later retrieve jobs.
155+
- Added long awaited job cancellation. You can use tags to cancel jobs.
156+
- Removed deprecated BaseJob class. This may break backward compatibility.
153157
- 1.1.2 (Feb 18, 2014)
154158
- Report exceptions to logger if addInBackground fails. (#31)
155159
- 1.1.1 (Feb 8, 2014)
@@ -224,15 +228,15 @@ THE SOFTWARE.
224228
</pre>
225229

226230

227-
[1]: https://github.com/path/android-priority-jobqueue/blob/master/jobqueue/src/com/path/android/jobqueue/network/NetworkUtil.java
228-
[2]: https://github.com/path/android-priority-jobqueue/blob/master/jobqueue/src/com/path/android/jobqueue/network/NetworkEventProvider.java
231+
[1]: https://github.com/yigit/android-priority-jobqueue/blob/master/jobqueue/src/com/path/android/jobqueue/network/NetworkUtil.java
232+
[2]: https://github.com/yigit/android-priority-jobqueue/blob/master/jobqueue/src/com/path/android/jobqueue/network/NetworkEventProvider.java
229233
[3]: http://path.github.io/android-priority-jobqueue/coverage-report/index.html
230234
[4]: http://path.github.io/android-priority-jobqueue/javadoc/index.html
231235
[5]: http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22android-priority-jobqueue%22
232-
[6]: https://github.com/path/android-priority-jobqueue/tree/master/examples
233-
[7]: https://github.com/path/android-priority-jobqueue/blob/master/examples/twitter/TwitterClient/src/com/path/android/jobqueue/examples/twitter/TwitterApplication.java#L26
236+
[6]: https://github.com/yigit/android-priority-jobqueue/tree/master/examples
237+
[7]: https://github.com/yigit/android-priority-jobqueue/blob/master/examples/twitter/TwitterClient/src/com/path/android/jobqueue/examples/twitter/TwitterApplication.java#L26
234238
[8]: http://www.youtube.com/watch?v=xHXn3Kg2IQE
235-
[9]: https://github.com/path/android-priority-jobqueue/wiki
236-
[10]: https://github.com/path/android-priority-jobqueue/wiki/Job-Manager-Configuration
237-
[11]: https://github.com/path/android-priority-jobqueue/wiki/Job-Configuration
238-
[12]: https://github.com/path/android-priority-jobqueue/blob/master/jobqueue/src/com/path/android/jobqueue/Params.java
239+
[9]: https://github.com/yigit/android-priority-jobqueue/wiki
240+
[10]: https://github.com/yigit/android-priority-jobqueue/wiki/Job-Manager-Configuration
241+
[11]: https://github.com/yigit/android-priority-jobqueue/wiki/Job-Configuration
242+
[12]: https://github.com/yigit/android-priority-jobqueue/blob/master/jobqueue/src/com/path/android/jobqueue/Params.java

examples/twitter/TwitterClient/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ android {
5959
dependencies {
6060
compile 'de.greenrobot:eventbus:2.1.0-beta-1'
6161
compile 'org.twitter4j:twitter4j-core:3.0.5'
62-
compile 'com.path:android-priority-jobqueue:1.1-SNAPSHOT'
62+
compile 'com.path:android-priority-jobqueue:1.1 -SNAPSHOT'
6363
compile files('external-libs/greenDAO.jar')
6464
}
6565

jobqueue/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.path.android.jobqueue"
44
android:versionCode="2"
5-
android:versionName="1.3-SNAPSHOT">
5+
android:versionName="1.3">
66
<application android:label="">
77
</application>
88
</manifest>

jobqueue/build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
</target>
159159

160160
<target name="coverage-report">
161-
<cobertura-report format="html" destdir="${coveragereport.dir}" srcdir="${src.dir}"/>
161+
<cobertura-report format="html" destdir="coverage-report" srcdir="${src.dir}"/>
162162
</target>
163163

164164
<target name="build-jar" depends="release" description="builds jar from compiled code">

jobqueue/src/com/path/android/jobqueue/BaseJob.java

Lines changed: 0 additions & 205 deletions
This file was deleted.

jobqueue/src/com/path/android/jobqueue/CancelResult.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,38 @@
22

33
import java.util.Collection;
44
import java.util.HashSet;
5+
import com.path.android.jobqueue.JobManager;
56

67
/**
7-
* Canceling jobs is an expensive operation because it requires JobManager to deserializer the job
8+
* This class holds the result of a cancel request via {@link JobManager#cancelJobs(TagConstraint, String...)}
9+
* or {@link JobManager#cancelJobsInBackground(CancelResult.AsyncCancelCallback, TagConstraint, String...)}.
10+
* <p>
11+
* Cancelling jobs is an expensive operation because it requires JobManager to deserializer the job
812
* from databases and call onCancel method on it.
913
* <p>
10-
* When cancelling jobs, if you need to get the list of canceled jobs, you can provide this
14+
* When cancelling jobs, if you need to get the list of cancelled jobs, you can provide this
1115
* callback to {@link JobManager#cancelJobsInBackground(CancelResult.AsyncCancelCallback, TagConstraint, String...)}
1216
* method.
1317
*/
1418
public class CancelResult {
15-
Collection<Job> canceledJobs;
19+
Collection<Job> cancelledJobs;
1620
Collection<Job> failedToCancel;
1721

1822
public CancelResult() {
19-
this.canceledJobs = new HashSet<Job>();
23+
this.cancelledJobs = new HashSet<Job>();
2024
this.failedToCancel = new HashSet<Job>();
2125
}
2226

2327
/**
24-
* @return The list of jobs that are canceled before they did run
28+
* @return The list of jobs that are cancelled before they did run
2529
*/
26-
public Collection<Job> getCanceledJobs() {
27-
return canceledJobs;
30+
public Collection<Job> getCancelledJobs() {
31+
return cancelledJobs;
2832
}
2933

3034
/**
3135
* @return The list of jobs that were running when cancel was called and finished running
32-
* successfully before they could be canceled.
36+
* successfully before they could be cancelled.
3337
*/
3438
public Collection<Job> getFailedToCancel() {
3539
return failedToCancel;
@@ -40,6 +44,6 @@ public static interface AsyncCancelCallback {
4044
/**
4145
* When job cancellation is complete, this method is called by the JobManager.
4246
*/
43-
public void onCanceled(CancelResult cancelResult);
47+
public void onCancelled(CancelResult cancelResult);
4448
}
4549
}

0 commit comments

Comments
 (0)