DownloadLog entries are now sorted by their completion date

This commit is contained in:
daniel oeh 2012-08-18 01:04:33 +02:00
parent fdb9a296ad
commit 1d890208e0
2 changed files with 19 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import de.danoeh.antennapod.asynctask.DownloadStatus;
import de.danoeh.antennapod.service.PlaybackService;
import de.danoeh.antennapod.storage.*;
import de.danoeh.antennapod.util.FeedtitleComparator;
import de.danoeh.antennapod.util.comparator.DownloadStatusComparator;
import de.danoeh.antennapod.util.comparator.FeedItemPubdateComparator;
import android.annotation.SuppressLint;
import android.content.Context;
@ -344,6 +345,7 @@ public class FeedManager {
} else {
removedStatus = null;
}
Collections.sort(downloadLog, new DownloadStatusComparator());
context.sendBroadcast(new Intent(ACTION_DOWNLOADLOG_UPDATE));
dbExec.execute(new Runnable() {
@ -973,6 +975,7 @@ public class FeedManager {
} while (logCursor.moveToNext());
}
logCursor.close();
Collections.sort(downloadLog, new DownloadStatusComparator());
}
private void extractQueueFromCursor(Context context, PodDBAdapter adapter) {

View File

@ -0,0 +1,16 @@
package de.danoeh.antennapod.util.comparator;
import java.util.Comparator;
import de.danoeh.antennapod.asynctask.DownloadStatus;
/** Compares the completion date of two Downloadstatus objects. */
public class DownloadStatusComparator implements Comparator<DownloadStatus> {
@Override
public int compare(DownloadStatus lhs, DownloadStatus rhs) {
return -lhs.getCompletionDate().compareTo(rhs.getCompletionDate());
}
}