Merge pull request #1788 from mfietz/issue/1489-cursor-allocation
Only have one cursor open at the same time
This commit is contained in:
commit
fb23dc4b61
|
@ -591,17 +591,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);
|
||||
}
|
||||
}
|
||||
itemCursor.close();
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -899,19 +900,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;
|
||||
|
|
Loading…
Reference in New Issue