diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-08-16 00:04:03 +0200 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-08-16 00:08:39 +0200 |
commit | 04bfcacb12425c7ea2196ae9290bc4afdd74003b (patch) | |
tree | b20e971159f88ad8fcab72f34d9b85f3c758675e | |
parent | 3148b8835b126b1afa5fc65653b07f9909b7582d (diff) | |
download | AntennaPod-04bfcacb12425c7ea2196ae9290bc4afdd74003b.zip |
Disable feed media file size service
3 files changed, 46 insertions, 60 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java index f47fe3944..e7283d860 100644 --- a/app/src/main/java/de/danoeh/antennapod/PodcastApp.java +++ b/app/src/main/java/de/danoeh/antennapod/PodcastApp.java @@ -1,13 +1,11 @@ package de.danoeh.antennapod; import android.app.Application; -import android.content.Intent; import android.content.res.Configuration; import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.service.FeedMediaSizeService; import de.danoeh.antennapod.core.util.NetworkUtils; import de.danoeh.antennapod.spa.SPAUtil; @@ -47,7 +45,7 @@ public class PodcastApp extends Application { SPAUtil.sendSPAppsQueryFeedsIntent(this); - startService(new Intent(this, FeedMediaSizeService.class)); + // startService(new Intent(this, FeedMediaSizeService.class)); } public static float getLogicalDensity() { diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/FeedMediaSizeService.java b/core/src/main/java/de/danoeh/antennapod/core/service/FeedMediaSizeService.java index 2f6e67a28..a8375bce3 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/FeedMediaSizeService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/FeedMediaSizeService.java @@ -4,19 +4,6 @@ import android.app.IntentService; import android.content.Intent; import android.util.Log; -import java.io.File; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.List; - -import de.danoeh.antennapod.core.event.FeedMediaEvent; -import de.danoeh.antennapod.core.feed.FeedMedia; -import de.danoeh.antennapod.core.storage.DBReader; -import de.danoeh.antennapod.core.storage.DBWriter; -import de.danoeh.antennapod.core.util.NetworkUtils; -import de.greenrobot.event.EventBus; - public class FeedMediaSizeService extends IntentService { private final static String TAG = "FeedMediaSizeService"; @@ -28,49 +15,50 @@ public class FeedMediaSizeService extends IntentService { @Override protected void onHandleIntent(Intent intent) { Log.d(TAG, "onHandleIntent()"); - if(false == NetworkUtils.isDownloadAllowed()) { - return; - } - List<FeedMedia> list = DBReader.getFeedMediaUnknownSize(this); - for (FeedMedia media : list) { - Log.d(TAG, "Getting size currently " + media.getSize() + " for " + media.getDownload_url()); - if(false == NetworkUtils.isDownloadAllowed()) { - return; - } - long size = Integer.MIN_VALUE; - if (media.isDownloaded()) { - File mediaFile = new File(media.getLocalMediaUrl()); - if(mediaFile.exists()) { - size = mediaFile.length(); - } - } else if (false == media.checkedOnSizeButUnknown()) { - // only query the network if we haven't already checked - HttpURLConnection conn = null; - try { - URL url = new URL(media.getDownload_url()); - conn = (HttpURLConnection) url.openConnection(); - conn.setRequestProperty("Accept-Encoding", ""); - conn.setRequestMethod("HEAD"); - size = conn.getContentLength(); - } catch (IOException e) { - Log.d(TAG, media.getDownload_url()); - e.printStackTrace(); - } finally { - if (conn != null) { - conn.disconnect(); - } - } - } - if (size <= 0) { - // they didn't tell us the size, but we don't want to keep querying on it - media.setCheckedOnSizeButUnknown(); - } else { - media.setSize(size); - } - Log.d(TAG, "Size now: " + media.getSize()); - DBWriter.setFeedMedia(this, media); - EventBus.getDefault().post(FeedMediaEvent.update(media)); - } + return; +// if(false == NetworkUtils.isDownloadAllowed()) { +// return; +// } +// List<FeedMedia> list = DBReader.getFeedMediaUnknownSize(this); +// for (FeedMedia media : list) { +// Log.d(TAG, "Getting size currently " + media.getSize() + " for " + media.getDownload_url()); +// if(false == NetworkUtils.isDownloadAllowed()) { +// return; +// } +// long size = Integer.MIN_VALUE; +// if (media.isDownloaded()) { +// File mediaFile = new File(media.getLocalMediaUrl()); +// if(mediaFile.exists()) { +// size = mediaFile.length(); +// } +// } else if (false == media.checkedOnSizeButUnknown()) { +// // only query the network if we haven't already checked +// HttpURLConnection conn = null; +// try { +// URL url = new URL(media.getDownload_url()); +// conn = (HttpURLConnection) url.openConnection(); +// conn.setRequestProperty("Accept-Encoding", ""); +// conn.setRequestMethod("HEAD"); +// size = conn.getContentLength(); +// } catch (IOException e) { +// Log.d(TAG, media.getDownload_url()); +// e.printStackTrace(); +// } finally { +// if (conn != null) { +// conn.disconnect(); +// } +// } +// } +// if (size <= 0) { +// // they didn't tell us the size, but we don't want to keep querying on it +// media.setCheckedOnSizeButUnknown(); +// } else { +// media.setSize(size); +// } +// Log.d(TAG, "Size now: " + media.getSize()); +// DBWriter.setFeedMedia(this, media); +// EventBus.getDefault().post(FeedMediaEvent.update(media)); +// } } } 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 770c4f7d7..6ced03c0e 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 @@ -578,7 +578,7 @@ public final class DBTasks { EventDistributor.getInstance().sendFeedUpdateBroadcast(); - context.startService(new Intent(context, FeedMediaSizeService.class)); + // context.startService(new Intent(context, FeedMediaSizeService.class)); return resultFeeds; } |