improved startup performance
This commit is contained in:
parent
52ca268730
commit
ac18572789
|
@ -565,32 +565,21 @@ public class FeedManager {
|
||||||
if (feedlistCursor.moveToFirst()) {
|
if (feedlistCursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
Date lastUpdate = new Date(
|
Date lastUpdate = new Date(
|
||||||
feedlistCursor.getLong(feedlistCursor
|
feedlistCursor.getLong(PodDBAdapter.KEY_LAST_UPDATE_INDEX));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_LASTUPDATE)));
|
|
||||||
Feed feed = new Feed(lastUpdate);
|
Feed feed = new Feed(lastUpdate);
|
||||||
|
|
||||||
feed.id = feedlistCursor.getLong(PodDBAdapter.KEY_ID_INDEX);
|
feed.id = feedlistCursor.getLong(PodDBAdapter.KEY_ID_INDEX);
|
||||||
feed.setTitle(feedlistCursor.getString(feedlistCursor
|
feed.setTitle(feedlistCursor.getString(PodDBAdapter.KEY_TITLE_INDEX));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_TITLE)));
|
feed.setLink(feedlistCursor.getString(PodDBAdapter.KEY_LINK_INDEX));
|
||||||
feed.setLink(feedlistCursor.getString(feedlistCursor
|
feed.setDescription(feedlistCursor.getString(PodDBAdapter.KEY_DESCRIPTION_INDEX));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_LINK)));
|
feed.setPaymentLink(feedlistCursor.getString(PodDBAdapter.KEY_PAYMENT_LINK_INDEX));
|
||||||
feed.setDescription(feedlistCursor.getString(feedlistCursor
|
feed.setAuthor(feedlistCursor.getString(PodDBAdapter.KEY_AUTHOR_INDEX));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_DESCRIPTION)));
|
feed.setLanguage(feedlistCursor.getString(PodDBAdapter.KEY_LANGUAGE_INDEX));
|
||||||
feed.setPaymentLink(feedlistCursor.getString(feedlistCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_PAYMENT_LINK)));
|
|
||||||
feed.setAuthor(feedlistCursor.getString(feedlistCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_AUTHOR)));
|
|
||||||
feed.setLanguage(feedlistCursor.getString(feedlistCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_LANGUAGE)));
|
|
||||||
feed.setImage(adapter.getFeedImage(feedlistCursor
|
feed.setImage(adapter.getFeedImage(feedlistCursor
|
||||||
.getLong(feedlistCursor
|
.getLong(PodDBAdapter.KEY_IMAGE_INDEX)));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_IMAGE))));
|
feed.file_url = feedlistCursor.getString(PodDBAdapter.KEY_FILE_URL_INDEX);
|
||||||
feed.file_url = feedlistCursor.getString(feedlistCursor
|
feed.download_url = feedlistCursor.getString(PodDBAdapter.KEY_DOWNLOAD_URL_INDEX);
|
||||||
.getColumnIndex(PodDBAdapter.KEY_FILE_URL));
|
feed.setDownloaded(feedlistCursor.getInt(PodDBAdapter.KEY_DOWNLOADED_INDEX) > 0);
|
||||||
feed.download_url = feedlistCursor.getString(feedlistCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_DOWNLOAD_URL));
|
|
||||||
feed.setDownloaded(feedlistCursor.getInt(feedlistCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_DOWNLOADED)) > 0);
|
|
||||||
// Get FeedItem-Object
|
// Get FeedItem-Object
|
||||||
Cursor itemlistCursor = adapter.getAllItemsOfFeedCursor(feed);
|
Cursor itemlistCursor = adapter.getAllItemsOfFeedCursor(feed);
|
||||||
feed.setItems(extractFeedItemsFromCursor(context, feed,
|
feed.setItems(extractFeedItemsFromCursor(context, feed,
|
||||||
|
@ -616,26 +605,18 @@ public class FeedManager {
|
||||||
|
|
||||||
item.id = itemlistCursor.getLong(PodDBAdapter.KEY_ID_INDEX);
|
item.id = itemlistCursor.getLong(PodDBAdapter.KEY_ID_INDEX);
|
||||||
item.setFeed(feed);
|
item.setFeed(feed);
|
||||||
item.setTitle(itemlistCursor.getString(itemlistCursor
|
item.setTitle(itemlistCursor.getString(PodDBAdapter.KEY_TITLE_INDEX));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_TITLE)));
|
item.setLink(itemlistCursor.getString(PodDBAdapter.KEY_LINK_INDEX));
|
||||||
item.setLink(itemlistCursor.getString(itemlistCursor
|
item.setDescription(itemlistCursor.getString(PodDBAdapter.KEY_DESCRIPTION_INDEX));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_LINK)));
|
item.setContentEncoded(itemlistCursor.getString(PodDBAdapter.KEY_CONTENT_ENCODED_INDEX));
|
||||||
item.setDescription(itemlistCursor.getString(itemlistCursor
|
item.setPubDate(new Date(itemlistCursor.getLong(PodDBAdapter.KEY_PUBDATE_INDEX)));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_DESCRIPTION)));
|
item.setPaymentLink(itemlistCursor.getString(PodDBAdapter.KEY_PAYMENT_LINK_INDEX));
|
||||||
item.setContentEncoded(itemlistCursor.getString(itemlistCursor
|
long mediaId = itemlistCursor.getLong(PodDBAdapter.KEY_MEDIA_INDEX);
|
||||||
.getColumnIndex(PodDBAdapter.KEY_CONTENT_ENCODED)));
|
|
||||||
item.setPubDate(new Date(itemlistCursor.getLong(itemlistCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_PUBDATE))));
|
|
||||||
item.setPaymentLink(itemlistCursor.getString(itemlistCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_PAYMENT_LINK)));
|
|
||||||
long mediaId = itemlistCursor.getLong(itemlistCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_MEDIA));
|
|
||||||
if (mediaId != 0) {
|
if (mediaId != 0) {
|
||||||
mediaIds.add(String.valueOf(mediaId));
|
mediaIds.add(String.valueOf(mediaId));
|
||||||
item.setMedia(new FeedMedia(mediaId, item));
|
item.setMedia(new FeedMedia(mediaId, item));
|
||||||
}
|
}
|
||||||
item.read = (itemlistCursor.getInt(itemlistCursor
|
item.read = (itemlistCursor.getInt(PodDBAdapter.KEY_READ_INDEX) > 0) ? true
|
||||||
.getColumnIndex(PodDBAdapter.KEY_READ)) > 0) ? true
|
|
||||||
: false;
|
: false;
|
||||||
if (!item.read) {
|
if (!item.read) {
|
||||||
unreadItems.add(item);
|
unreadItems.add(item);
|
||||||
|
@ -643,8 +624,7 @@ public class FeedManager {
|
||||||
|
|
||||||
// extract chapters
|
// extract chapters
|
||||||
boolean hasSimpleChapters = itemlistCursor
|
boolean hasSimpleChapters = itemlistCursor
|
||||||
.getInt(itemlistCursor
|
.getInt(PodDBAdapter.KEY_HAS_SIMPLECHAPTERS_INDEX) > 0;
|
||||||
.getColumnIndex(PodDBAdapter.KEY_HAS_SIMPLECHAPTERS)) > 0;
|
|
||||||
if (hasSimpleChapters) {
|
if (hasSimpleChapters) {
|
||||||
Cursor chapterCursor = adapter
|
Cursor chapterCursor = adapter
|
||||||
.getSimpleChaptersOfFeedItemCursor(item);
|
.getSimpleChaptersOfFeedItemCursor(item);
|
||||||
|
@ -653,10 +633,8 @@ public class FeedManager {
|
||||||
do {
|
do {
|
||||||
SimpleChapter chapter = new SimpleChapter(
|
SimpleChapter chapter = new SimpleChapter(
|
||||||
chapterCursor
|
chapterCursor
|
||||||
.getLong(chapterCursor
|
.getLong(PodDBAdapter.KEY_SC_START_INDEX),
|
||||||
.getColumnIndex(PodDBAdapter.KEY_START)),
|
chapterCursor.getString(PodDBAdapter.KEY_TITLE_INDEX));
|
||||||
chapterCursor.getString(chapterCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_TITLE)));
|
|
||||||
item.getSimpleChapters().add(chapter);
|
item.getSimpleChapters().add(chapter);
|
||||||
} while (chapterCursor.moveToNext());
|
} while (chapterCursor.moveToNext());
|
||||||
}
|
}
|
||||||
|
@ -685,20 +663,13 @@ public class FeedManager {
|
||||||
item.setMedia(new FeedMedia(
|
item.setMedia(new FeedMedia(
|
||||||
mediaId,
|
mediaId,
|
||||||
item,
|
item,
|
||||||
cursor.getInt(cursor
|
cursor.getInt(PodDBAdapter.KEY_DURATION_INDEX),
|
||||||
.getColumnIndex(PodDBAdapter.KEY_DURATION)),
|
cursor.getInt(PodDBAdapter.KEY_POSITION_INDEX),
|
||||||
cursor.getInt(cursor
|
cursor.getLong(PodDBAdapter.KEY_SIZE_INDEX),
|
||||||
.getColumnIndex(PodDBAdapter.KEY_POSITION)),
|
cursor.getString(PodDBAdapter.KEY_MIME_TYPE_INDEX),
|
||||||
cursor.getLong(cursor
|
cursor.getString(PodDBAdapter.KEY_FILE_URL_INDEX),
|
||||||
.getColumnIndex(PodDBAdapter.KEY_SIZE)),
|
cursor.getString(PodDBAdapter.KEY_DOWNLOAD_URL_INDEX),
|
||||||
cursor.getString(cursor
|
cursor.getInt(PodDBAdapter.KEY_DOWNLOADED_INDEX) > 0));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_MIME_TYPE)),
|
|
||||||
cursor.getString(cursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_FILE_URL)),
|
|
||||||
cursor.getString(cursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_DOWNLOAD_URL)),
|
|
||||||
cursor.getInt(cursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_DOWNLOADED)) > 0));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
|
@ -723,10 +694,8 @@ public class FeedManager {
|
||||||
if (logCursor.moveToFirst()) {
|
if (logCursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
long id = logCursor.getLong(PodDBAdapter.KEY_ID_INDEX);
|
long id = logCursor.getLong(PodDBAdapter.KEY_ID_INDEX);
|
||||||
long feedfileId = logCursor.getLong(logCursor
|
long feedfileId = logCursor.getLong(PodDBAdapter.KEY_FEEDFILE_INDEX);
|
||||||
.getColumnIndex(PodDBAdapter.KEY_FEEDFILE));
|
int feedfileType = logCursor.getInt(PodDBAdapter.KEY_FEEDFILETYPE_INDEX);
|
||||||
int feedfileType = logCursor.getInt(logCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_FEEDFILETYPE));
|
|
||||||
FeedFile feedfile = null;
|
FeedFile feedfile = null;
|
||||||
switch (feedfileType) {
|
switch (feedfileType) {
|
||||||
case PodDBAdapter.FEEDFILETYPE_FEED:
|
case PodDBAdapter.FEEDFILETYPE_FEED:
|
||||||
|
@ -739,12 +708,9 @@ public class FeedManager {
|
||||||
feedfile = getFeedMedia(feedfileId);
|
feedfile = getFeedMedia(feedfileId);
|
||||||
}
|
}
|
||||||
if (feedfile != null) { // otherwise ignore status
|
if (feedfile != null) { // otherwise ignore status
|
||||||
boolean successful = logCursor.getInt(logCursor
|
boolean successful = logCursor.getInt(PodDBAdapter.KEY_SUCCESSFUL_INDEX) > 0;
|
||||||
.getColumnIndex(PodDBAdapter.KEY_SUCCESSFUL)) > 0;
|
int reason = logCursor.getInt(PodDBAdapter.KEY_REASON_INDEX);
|
||||||
int reason = logCursor.getInt(logCursor
|
Date completionDate = new Date(logCursor.getLong(PodDBAdapter.KEY_COMPLETION_DATE_INDEX));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_REASON));
|
|
||||||
Date completionDate = new Date(logCursor.getLong(logCursor
|
|
||||||
.getColumnIndex(PodDBAdapter.KEY_COMPLETION_DATE)));
|
|
||||||
downloadLog.add(new DownloadStatus(id, feedfile,
|
downloadLog.add(new DownloadStatus(id, feedfile,
|
||||||
successful, reason, completionDate));
|
successful, reason, completionDate));
|
||||||
}
|
}
|
||||||
|
@ -760,11 +726,9 @@ public class FeedManager {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
int index = cursor.getInt(PodDBAdapter.KEY_ID_INDEX);
|
int index = cursor.getInt(PodDBAdapter.KEY_ID_INDEX);
|
||||||
Feed feed = getFeed(cursor.getLong(cursor
|
Feed feed = getFeed(cursor.getLong(PodDBAdapter.KEY_QUEUE_FEED_INDEX));
|
||||||
.getColumnIndex(PodDBAdapter.KEY_FEED)));
|
|
||||||
if (feed != null) {
|
if (feed != null) {
|
||||||
FeedItem item = getFeedItem(cursor.getLong(cursor
|
FeedItem item = getFeedItem(cursor.getLong(PodDBAdapter.KEY_FEEDITEM_INDEX), feed);
|
||||||
.getColumnIndex(PodDBAdapter.KEY_FEEDITEM)), feed);
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
queue.add(index, item);
|
queue.add(index, item);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue