Skip to content

Commit 7587484

Browse files
committed
Rejected Exception fix for version 1.1.4
Rejected Exception fix for version 1.1.4
1 parent 62d21c1 commit 7587484

File tree

6 files changed

+119
-110
lines changed

6 files changed

+119
-110
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Version 1.1.5
2+
- bug fixes
3+
14
Version 1.1.4
25
- bug fixes
36
- Android Oreo compatability

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[ ![Download](https://api.bintray.com/packages/tonyofrancis/maven/fetch/images/download.svg?version=1.1.4) ](https://bintray.com/tonyofrancis/maven/fetch/1.1.4/link)
1+
[ ![Download](https://api.bintray.com/packages/tonyofrancis/maven/fetch/images/download.svg?version=1.1.5) ](https://bintray.com/tonyofrancis/maven/fetch/1.1.5/link)
22
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android%20Networking-blue.svg?style=flat)](https://android-arsenal.com/details/1/5196)
33
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/tonyofrancis/Fetch/blob/master/LICENSE)
44

@@ -44,7 +44,7 @@ Using Fetch is easy! Just add the Gradle dependency to your application's build.
4444
file.
4545

4646
```java
47-
compile 'com.tonyodev.fetch:fetch:1.1.4'
47+
compile 'com.tonyodev.fetch:fetch:1.1.5'
4848
```
4949

5050
Next, get an instance of Fetch and request a download. A unique ID will be returned

app/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 26
5-
buildToolsVersion '26.0.2'
4+
compileSdkVersion 27
5+
buildToolsVersion '27.0.2'
66
defaultConfig {
77
applicationId "com.tonyodev.fetchdemo"
88
minSdkVersion 16
9-
targetSdkVersion 26
9+
targetSdkVersion 27
1010
versionCode 3
1111
versionName "3.0"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -26,8 +26,8 @@ dependencies {
2626
})
2727
testCompile 'junit:junit:4.12'
2828

29-
compile 'com.android.support:appcompat-v7:26.1.0'
30-
compile 'com.android.support:recyclerview-v7:26.1.0'
31-
compile 'com.android.support:design:26.1.0'
29+
compile 'com.android.support:appcompat-v7:27.0.2'
30+
compile 'com.android.support:recyclerview-v7:27.0.2'
31+
compile 'com.android.support:design:27.0.2'
3232
compile project(':fetch')
3333
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
jcenter()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.0.0-rc1'
9+
classpath 'com.android.tools.build:gradle:3.0.1'
1010

1111

1212
// NOTE: Do not place your application dependencies here; they belong

fetch/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 26
5-
buildToolsVersion '26.0.2'
4+
compileSdkVersion 27
5+
buildToolsVersion '27.0.2'
66

77
defaultConfig {
88
minSdkVersion 16
9-
targetSdkVersion 26
10-
versionCode 9
11-
versionName "1.1.4"
9+
targetSdkVersion 27
10+
versionCode 10
11+
versionName "1.1.5"
1212

1313
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1414

@@ -26,6 +26,6 @@ dependencies {
2626
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
2727
exclude group: 'com.android.support', module: 'support-annotations'
2828
})
29-
compile 'com.android.support:appcompat-v7:26.1.0'
29+
compile 'com.android.support:appcompat-v7:27.0.2'
3030
testCompile 'junit:junit:4.12'
3131
}

fetch/src/main/java/com/tonyodev/fetch/FetchService.java

Lines changed: 101 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -224,103 +224,109 @@ public void shutdown() {
224224
}
225225

226226
private void processAction(final Bundle bundle) {
227-
if (!executor.isShutdown()) {
228-
229-
executor.execute(new Runnable() {
230-
@Override
231-
public void run() {
232-
233-
databaseHelper.clean();
234-
235-
final long id = bundle.getLong(EXTRA_ID, DEFAULT_EMPTY_VALUE);
236-
237-
switch (bundle.getInt(ACTION_TYPE, DEFAULT_EMPTY_VALUE)) {
238-
239-
case ACTION_PAUSE: {
240-
pause(id);
241-
break;
242-
}
243-
case ACTION_REMOVE: {
244-
remove(id);
245-
break;
246-
}
247-
case ACTION_RESUME: {
248-
resume(id);
249-
break;
250-
}
251-
case ACTION_ENQUEUE: {
252-
String url = bundle.getString(EXTRA_URL);
253-
String filePath = bundle.getString(EXTRA_FILE_PATH);
254-
ArrayList<Bundle> headers = bundle.getParcelableArrayList(EXTRA_HEADERS);
255-
int priority = bundle.getInt(EXTRA_PRIORITY, PRIORITY_NORMAL);
256-
257-
enqueue(url, filePath, headers, priority);
258-
break;
259-
}
260-
case ACTION_NETWORK: {
261-
int network = bundle.getInt(EXTRA_NETWORK_ID, NETWORK_ALL);
262-
setAllowedNetwork(network);
263-
break;
264-
}
265-
case ACTION_LOGGING: {
266-
boolean enabled = bundle.getBoolean(EXTRA_LOGGING_ID, true);
267-
setLoggingEnabled(enabled);
268-
break;
269-
}
270-
case ACTION_PROCESS_PENDING: {
271-
startDownload();
272-
break;
273-
}
274-
case ACTION_QUERY: {
275-
long queryId = bundle.getLong(EXTRA_QUERY_ID, DEFAULT_EMPTY_VALUE);
276-
int queryType = bundle.getInt(EXTRA_QUERY_TYPE, QUERY_ALL);
277-
int status = bundle.getInt(EXTRA_STATUS, DEFAULT_EMPTY_VALUE);
278-
query(queryType, queryId, id, status);
279-
break;
280-
}
281-
case ACTION_PRIORITY: {
282-
int priority = bundle.getInt(EXTRA_PRIORITY, PRIORITY_NORMAL);
283-
setRequestPriority(id, priority);
284-
break;
285-
}
286-
case ACTION_RETRY: {
287-
retry(id);
288-
break;
289-
}
290-
case ACTION_REMOVE_ALL: {
291-
removeAll();
292-
break;
293-
}
294-
case ACTION_CONCURRENT_DOWNLOADS_LIMIT: {
295-
int limit = bundle.getInt(EXTRA_CONCURRENT_DOWNLOADS_LIMIT, DEFAULT_DOWNLOADS_LIMIT);
296-
setDownloadsLimit(limit);
297-
break;
298-
}
299-
case ACTION_ON_UPDATE_INTERVAL: {
300-
long interval = bundle.getLong(EXTRA_ON_UPDATE_INTERVAL, DEFAULT_ON_UPDATE_INTERVAL);
301-
setOnUpdateInterval(interval);
302-
break;
303-
}
304-
case ACTION_UPDATE_REQUEST_URL: {
305-
String url = bundle.getString(EXTRA_URL);
306-
updateRequestUrl(id, url);
307-
break;
308-
}
309-
case ACTION_REMOVE_REQUEST: {
310-
removeRequest(id);
311-
break;
312-
}
313-
case ACTION_REMOVE_REQUEST_ALL: {
314-
removeRequestAll();
315-
break;
316-
}
317-
default: {
318-
startDownload();
319-
break;
227+
try {
228+
if (!executor.isShutdown()) {
229+
230+
executor.execute(new Runnable() {
231+
@Override
232+
public void run() {
233+
234+
databaseHelper.clean();
235+
236+
final long id = bundle.getLong(EXTRA_ID, DEFAULT_EMPTY_VALUE);
237+
238+
switch (bundle.getInt(ACTION_TYPE, DEFAULT_EMPTY_VALUE)) {
239+
240+
case ACTION_PAUSE: {
241+
pause(id);
242+
break;
243+
}
244+
case ACTION_REMOVE: {
245+
remove(id);
246+
break;
247+
}
248+
case ACTION_RESUME: {
249+
resume(id);
250+
break;
251+
}
252+
case ACTION_ENQUEUE: {
253+
String url = bundle.getString(EXTRA_URL);
254+
String filePath = bundle.getString(EXTRA_FILE_PATH);
255+
ArrayList<Bundle> headers = bundle.getParcelableArrayList(EXTRA_HEADERS);
256+
int priority = bundle.getInt(EXTRA_PRIORITY, PRIORITY_NORMAL);
257+
258+
enqueue(url, filePath, headers, priority);
259+
break;
260+
}
261+
case ACTION_NETWORK: {
262+
int network = bundle.getInt(EXTRA_NETWORK_ID, NETWORK_ALL);
263+
setAllowedNetwork(network);
264+
break;
265+
}
266+
case ACTION_LOGGING: {
267+
boolean enabled = bundle.getBoolean(EXTRA_LOGGING_ID, true);
268+
setLoggingEnabled(enabled);
269+
break;
270+
}
271+
case ACTION_PROCESS_PENDING: {
272+
startDownload();
273+
break;
274+
}
275+
case ACTION_QUERY: {
276+
long queryId = bundle.getLong(EXTRA_QUERY_ID, DEFAULT_EMPTY_VALUE);
277+
int queryType = bundle.getInt(EXTRA_QUERY_TYPE, QUERY_ALL);
278+
int status = bundle.getInt(EXTRA_STATUS, DEFAULT_EMPTY_VALUE);
279+
query(queryType, queryId, id, status);
280+
break;
281+
}
282+
case ACTION_PRIORITY: {
283+
int priority = bundle.getInt(EXTRA_PRIORITY, PRIORITY_NORMAL);
284+
setRequestPriority(id, priority);
285+
break;
286+
}
287+
case ACTION_RETRY: {
288+
retry(id);
289+
break;
290+
}
291+
case ACTION_REMOVE_ALL: {
292+
removeAll();
293+
break;
294+
}
295+
case ACTION_CONCURRENT_DOWNLOADS_LIMIT: {
296+
int limit = bundle.getInt(EXTRA_CONCURRENT_DOWNLOADS_LIMIT, DEFAULT_DOWNLOADS_LIMIT);
297+
setDownloadsLimit(limit);
298+
break;
299+
}
300+
case ACTION_ON_UPDATE_INTERVAL: {
301+
long interval = bundle.getLong(EXTRA_ON_UPDATE_INTERVAL, DEFAULT_ON_UPDATE_INTERVAL);
302+
setOnUpdateInterval(interval);
303+
break;
304+
}
305+
case ACTION_UPDATE_REQUEST_URL: {
306+
String url = bundle.getString(EXTRA_URL);
307+
updateRequestUrl(id, url);
308+
break;
309+
}
310+
case ACTION_REMOVE_REQUEST: {
311+
removeRequest(id);
312+
break;
313+
}
314+
case ACTION_REMOVE_REQUEST_ALL: {
315+
removeRequestAll();
316+
break;
317+
}
318+
default: {
319+
startDownload();
320+
break;
321+
}
320322
}
321323
}
322-
}
323-
});
324+
});
325+
}
326+
} catch (Exception e) {
327+
if (loggingEnabled) {
328+
e.printStackTrace();
329+
}
324330
}
325331
}
326332

0 commit comments

Comments
 (0)