diff options
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java index 68187306d..61a07ae2d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java @@ -590,17 +590,18 @@ public final class DBReader { FeedItem item = null; Cursor itemCursor = adapter.getFeedItemCursor(Long.toString(itemId)); - if (itemCursor.moveToFirst()) { - List<FeedItem> list = extractItemlistFromCursor(adapter, itemCursor); - if (list.size() > 0) { - item = list.get(0); - loadAdditionalFeedItemListData(list); - if (item.hasChapters()) { - loadChaptersOfFeedItem(adapter, item); - } - } + if (!itemCursor.moveToFirst()) { + return null; } + List<FeedItem> list = extractItemlistFromCursor(adapter, itemCursor); itemCursor.close(); + if (list.size() > 0) { + item = list.get(0); + loadAdditionalFeedItemListData(list); + if (item.hasChapters()) { + loadChaptersOfFeedItem(adapter, item); + } + } return item; } @@ -898,19 +899,23 @@ public final class DBReader { adapter.open(); Cursor mediaCursor = adapter.getSingleFeedMediaCursor(mediaId); - FeedMedia media = null; - if (mediaCursor.moveToFirst()) { - int indexFeedItem = mediaCursor.getColumnIndex(PodDBAdapter.KEY_FEEDITEM); - final long itemId = mediaCursor.getLong(indexFeedItem); - media = FeedMedia.fromCursor(mediaCursor); + if (!mediaCursor.moveToFirst()) { + return null; + } + + int indexFeedItem = mediaCursor.getColumnIndex(PodDBAdapter.KEY_FEEDITEM); + long itemId = mediaCursor.getLong(indexFeedItem); + FeedMedia media = FeedMedia.fromCursor(mediaCursor); + mediaCursor.close(); + + if(media != null) { FeedItem item = getFeedItem(itemId); - if (media != null && item != null) { + if (item != null) { media.setItem(item); item.setMedia(media); } } - mediaCursor.close(); adapter.close(); return media; |