Pause download service if no network (#783)

* Add setupTableDrawerAdapter() function to simply KiwixMobileActivity.onCreate().

BUG: #565

*  Pause DownloadService if network is not available

* Revert changes to KiwixMobileActivity.java

* Negation on the network availability condition.

(cherry picked from commit 873218352f083c9d5dd2eff2f8cb597b52c33dbc)
This commit is contained in:
qinyin 2018-07-01 20:44:02 +02:00 committed by Abdul Wadood
parent 10fdfc6f96
commit 97afab67db

View File

@ -142,8 +142,7 @@ public class DownloadService extends Service {
if (intent == null) { if (intent == null) {
return START_NOT_STICKY; return START_NOT_STICKY;
} }
String log = intent.getAction(); String log = intent.getAction() + " : ";
log += " : ";
if (intent.hasExtra(NOTIFICATION_ID)) { if (intent.hasExtra(NOTIFICATION_ID)) {
log += intent.getIntExtra(NOTIFICATION_ID, -3); log += intent.getIntExtra(NOTIFICATION_ID, -3);
} }
@ -567,7 +566,8 @@ public class DownloadService extends Service {
break; break;
} }
if (MainActivity.wifiOnly && !NetworkUtils.isWiFi(getApplicationContext())) { if (MainActivity.wifiOnly && !NetworkUtils.isWiFi(getApplicationContext()) ||
!NetworkUtils.isNetworkAvailable(getApplicationContext())) {
pauseDownload(chunk.getNotificationID()); pauseDownload(chunk.getNotificationID());
} }