diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-12-15 16:36:15 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-12-15 16:36:15 +0100 |
commit | 6113b932b4ccc49ff641e195d7afc2abb8a9d6ef (patch) | |
tree | 68716237e61085cc261b6ba4639e03ceeac78d79 /core/src/main/java | |
parent | 755bdc5afbbfc18fa14657cbc343d61253874146 (diff) | |
download | AntennaPod-6113b932b4ccc49ff641e195d7afc2abb8a9d6ef.zip |
DownloadService: media item might be null
Diffstat (limited to 'core/src/main/java')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index f7e084e20..9768bd5de 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -72,7 +72,6 @@ import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.syndication.handler.FeedHandler; import de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult; import de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException; -import de.danoeh.antennapod.core.util.ChapterUtils; import de.danoeh.antennapod.core.util.DownloadError; import de.danoeh.antennapod.core.util.InvalidFeedException; import de.greenrobot.event.EventBus; @@ -1032,7 +1031,6 @@ public class DownloadService extends Service { throw new IllegalStateException( "Could not find downloaded media object in database"); } - boolean chaptersRead = false; media.setDownloaded(true); media.setFile_url(request.getDestination()); media.setHasEmbeddedPicture(null); @@ -1055,23 +1053,18 @@ public class DownloadService extends Service { } } - if (media.getItem().getChapters() == null) { - ChapterUtils.loadChaptersFromFileUrl(media); - if (media.getItem().getChapters() != null) { - chaptersRead = true; - } - } + final FeedItem item = media.getItem(); try { // we've received the media, we don't want to autodownload it again - FeedItem item = media.getItem(); - item.setAutoDownload(false); - - // update the db - DBWriter.setFeedItem(item).get(); + if(item != null) { + item.setAutoDownload(false); + DBWriter.setFeedItem(item).get(); + } DBWriter.setFeedMedia(media).get(); - if (!DBTasks.isInQueue(DownloadService.this, item.getId())) { + + if (item != null && !DBTasks.isInQueue(DownloadService.this, item.getId())) { DBWriter.addQueueItem(DownloadService.this, item).get(); } } catch (ExecutionException e) { @@ -1084,13 +1077,12 @@ public class DownloadService extends Service { saveDownloadStatus(status); - if(GpodnetPreferences.loggedIn()) { - FeedItem item = media.getItem(); - GpodnetEpisodeAction action = new GpodnetEpisodeAction.Builder(item, Action.DOWNLOAD) - .currentDeviceId() - .currentTimestamp() - .build(); - GpodnetPreferences.enqueueEpisodeAction(action); + if(GpodnetPreferences.loggedIn() && item != null) { + GpodnetEpisodeAction action = new GpodnetEpisodeAction.Builder(item, Action.DOWNLOAD) + .currentDeviceId() + .currentTimestamp() + .build(); + GpodnetPreferences.enqueueEpisodeAction(action); } numberOfDownloads.decrementAndGet(); |