use of de.danoeh.antennapod.core.feed.FeedItem in project AntennaPod by AntennaPod.
the class DBReader method getQueue.
static List<FeedItem> getQueue(PodDBAdapter adapter) {
Log.d(TAG, "getQueue()");
Cursor itemlistCursor = adapter.getQueueCursor();
List<FeedItem> items = extractItemlistFromCursor(adapter, itemlistCursor);
itemlistCursor.close();
loadAdditionalFeedItemListData(items);
return items;
}
use of de.danoeh.antennapod.core.feed.FeedItem in project AntennaPod by AntennaPod.
the class DBReader method getFeedItem.
static FeedItem getFeedItem(final String podcastUrl, final String episodeUrl, PodDBAdapter adapter) {
Log.d(TAG, "Loading feeditem with podcast url " + podcastUrl + " and episode url " + episodeUrl);
FeedItem item = null;
Cursor itemCursor = adapter.getFeedItemCursor(podcastUrl, episodeUrl);
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);
}
}
}
itemCursor.close();
return item;
}
use of de.danoeh.antennapod.core.feed.FeedItem in project AntennaPod by AntennaPod.
the class DBReader method extractItemlistFromCursor.
private static List<FeedItem> extractItemlistFromCursor(PodDBAdapter adapter, Cursor cursor) {
List<FeedItem> result = new ArrayList<>(cursor.getCount());
LongList imageIds = new LongList(cursor.getCount());
LongList itemIds = new LongList(cursor.getCount());
if (cursor.moveToFirst()) {
do {
int indexImage = cursor.getColumnIndex(PodDBAdapter.KEY_IMAGE);
long imageId = cursor.getLong(indexImage);
imageIds.add(imageId);
FeedItem item = FeedItem.fromCursor(cursor);
result.add(item);
itemIds.add(item.getId());
} while (cursor.moveToNext());
Map<Long, FeedImage> images = getFeedImages(adapter, imageIds.toArray());
Map<Long, FeedMedia> medias = getFeedMedia(adapter, itemIds.toArray());
for (int i = 0; i < result.size(); i++) {
FeedItem item = result.get(i);
long imageId = imageIds.get(i);
FeedImage image = images.get(imageId);
item.setImage(image);
FeedMedia media = medias.get(item.getId());
item.setMedia(media);
if (media != null) {
media.setItem(item);
}
}
}
return result;
}
use of de.danoeh.antennapod.core.feed.FeedItem in project AntennaPod by AntennaPod.
the class DBReader method getFeedItem.
/**
* Loads a specific FeedItem from the database. This method should not be used for loading more
* than one FeedItem because this method might query the database several times for each item.
*
* @param itemId The ID of the FeedItem
* @return The FeedItem or null if the FeedItem could not be found. All FeedComponent-attributes
* as well as chapter marks of the FeedItem will also be loaded from the database.
*/
public static FeedItem getFeedItem(final long itemId) {
Log.d(TAG, "getFeedItem() called with: " + "itemId = [" + itemId + "]");
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
FeedItem item = getFeedItem(itemId, adapter);
adapter.close();
return item;
}
use of de.danoeh.antennapod.core.feed.FeedItem in project AntennaPod by AntennaPod.
the class FeedSearcher method performSearch.
/**
* Search through a feed, or all feeds, for episodes that match the query in either the title,
* chapter, or show notes. The search is first performed on titles, then chapters, and finally
* show notes. The list of resulting episodes also describes where the first match occurred
* (title, chapters, or show notes).
*
* @param context
* @param query search query
* @param selectedFeed feed to search, 0 to search through all feeds
* @return list of episodes containing the query
*/
public static List<SearchResult> performSearch(final Context context, final String query, final long selectedFeed) {
final int[] values = { 2, 1, 0, 0 };
final String[] subtitles = { context.getString(R.string.found_in_title_label), context.getString(R.string.found_in_chapters_label), context.getString(R.string.found_in_shownotes_label), context.getString(R.string.found_in_shownotes_label) };
List<SearchResult> result = new ArrayList<>();
List<FutureTask<List<FeedItem>>> tasks = new ArrayList<>();
tasks.add(DBTasks.searchFeedItemTitle(context, selectedFeed, query));
tasks.add(DBTasks.searchFeedItemChapters(context, selectedFeed, query));
tasks.add(DBTasks.searchFeedItemDescription(context, selectedFeed, query));
tasks.add(DBTasks.searchFeedItemContentEncoded(context, selectedFeed, query));
for (FutureTask<List<FeedItem>> task : tasks) {
task.run();
}
try {
for (int i = 0; i < tasks.size(); i++) {
FutureTask<List<FeedItem>> task = tasks.get(i);
List<FeedItem> items = task.get();
for (FeedItem item : items) {
if (result.isEmpty() || !isDuplicate(result, item)) {
result.add(new SearchResult(item, values[i], subtitles[i]));
}
}
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
Collections.sort(result, new SearchResultValueComparator());
return result;
}
Aggregations