diff options
author | Tom Hennen <tom.hennen@gmail.com> | 2015-01-06 21:42:04 -0500 |
---|---|---|
committer | Tom Hennen <tom.hennen@gmail.com> | 2015-01-06 21:42:04 -0500 |
commit | fe5d1debc295efaf526bbf381c9105a38dad65e4 (patch) | |
tree | c143d36fef2ec8b4edb248926a91a89ff369ec1a /core/src/main | |
parent | abc1c8a8dc39d36acc40545b59fc5b1e802917e1 (diff) | |
download | AntennaPod-fe5d1debc295efaf526bbf381c9105a38dad65e4.zip |
made conditional for auto-download easier to read, moved log message output to a better spot
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java | 18 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java | 3 |
2 files changed, 14 insertions, 7 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java index b02e621ae..96baeeb96 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java @@ -463,12 +463,20 @@ public final class DBTasks { return autodownloadExec.submit(new Runnable() { @Override public void run() { - if (BuildConfig.DEBUG) + + // true if we should auto download based on network status + boolean networkShouldAutoDl = NetworkUtils.autodownloadNetworkAvailable(context) + && UserPreferences.isEnableAutodownload(); + + // true if we should auto download based on power status + boolean powerShouldAutoDl = PowerUtils.deviceCharging(context) + || UserPreferences.isEnableAutodownloadOnBattery(); + + // we should only auto download if both network AND power are happy + if (networkShouldAutoDl && powerShouldAutoDl) { + Log.d(TAG, "Performing auto-dl of undownloaded episodes"); - if ((NetworkUtils.autodownloadNetworkAvailable(context) - && UserPreferences.isEnableAutodownload()) - && (PowerUtils.deviceCharging(context) - || UserPreferences.isEnableAutodownloadOnBattery())) { + final List<FeedItem> queue = DBReader.getQueue(context); final List<FeedItem> unreadItems = DBReader .getUnreadItemsList(context); diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java index a94bf43d7..d0cdad649 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java @@ -255,8 +255,7 @@ public class DownloadRequester { * Cancels all running downloads */ public synchronized void cancelAllDownloads(Context context) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Cancelling all running downloads"); + Log.d(TAG, "Cancelling all running downloads"); context.sendBroadcast(new Intent( DownloadService.ACTION_CANCEL_ALL_DOWNLOADS)); } |