use of de.danoeh.antennapod.core.util.comparator.DownloadStatusComparator in project AntennaPod by AntennaPod.
the class DBReader method getDownloadLog.
/**
* Loads the download log from the database.
*
* @return A list with DownloadStatus objects that represent the download log.
* The size of the returned list is limited by {@link #DOWNLOAD_LOG_SIZE}.
*/
public static List<DownloadStatus> getDownloadLog() {
Log.d(TAG, "getDownloadLog() called");
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
Cursor logCursor = adapter.getDownloadLogCursor(DOWNLOAD_LOG_SIZE);
List<DownloadStatus> downloadLog = new ArrayList<>(logCursor.getCount());
if (logCursor.moveToFirst()) {
do {
DownloadStatus status = DownloadStatus.fromCursor(logCursor);
downloadLog.add(status);
} while (logCursor.moveToNext());
}
logCursor.close();
adapter.close();
Collections.sort(downloadLog, new DownloadStatusComparator());
return downloadLog;
}
use of de.danoeh.antennapod.core.util.comparator.DownloadStatusComparator in project AntennaPod by AntennaPod.
the class DBReader method getFeedDownloadLog.
/**
* Loads the download log for a particular feed from the database.
*
* @param feed Feed for which the download log is loaded
* @return A list with DownloadStatus objects that represent the feed's download log,
* newest events first.
*/
public static List<DownloadStatus> getFeedDownloadLog(Feed feed) {
Log.d(TAG, "getFeedDownloadLog() called with: " + "feed = [" + feed + "]");
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
Cursor cursor = adapter.getDownloadLog(Feed.FEEDFILETYPE_FEED, feed.getId());
List<DownloadStatus> downloadLog = new ArrayList<>(cursor.getCount());
if (cursor.moveToFirst()) {
do {
DownloadStatus status = DownloadStatus.fromCursor(cursor);
downloadLog.add(status);
} while (cursor.moveToNext());
}
cursor.close();
adapter.close();
Collections.sort(downloadLog, new DownloadStatusComparator());
return downloadLog;
}
Aggregations