diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-04-06 14:14:16 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-04-06 14:14:16 +0200 |
commit | ab34475b758029db8d5b9bdd4aa91b6a5f205cf3 (patch) | |
tree | 06651b19e2b906bdcc0f48e4ead11f5d985839b3 /src/de/danoeh/antennapod | |
parent | aedead0106d3a2e57bb50ea1ad1908a191f7fe2b (diff) | |
download | AntennaPod-ab34475b758029db8d5b9bdd4aa91b6a5f205cf3.zip |
Fixed IndexOutOfBoundsException in extractQueueFromCursor
Diffstat (limited to 'src/de/danoeh/antennapod')
-rw-r--r-- | src/de/danoeh/antennapod/feed/FeedManager.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java index c7f317b62..d679e4dfa 100644 --- a/src/de/danoeh/antennapod/feed/FeedManager.java +++ b/src/de/danoeh/antennapod/feed/FeedManager.java @@ -7,6 +7,9 @@ import java.util.Collections; import java.util.Date; import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.TreeSet; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; @@ -1627,6 +1630,10 @@ public class FeedManager { if (AppConfig.DEBUG) Log.d(TAG, "Extracting Queue"); Cursor cursor = adapter.getQueueCursor(); + + // Sort cursor results by ID with TreeMap + TreeMap<Integer, FeedItem> map = new TreeMap<Integer, FeedItem>(); + if (cursor.moveToFirst()) { do { int index = cursor.getInt(PodDBAdapter.KEY_ID_INDEX); @@ -1637,13 +1644,17 @@ public class FeedManager { cursor.getLong(PodDBAdapter.KEY_FEEDITEM_INDEX), feed); if (item != null) { - queue.add(index, item); + map.put(index, item); } } - } while (cursor.moveToNext()); } cursor.close(); + + for (Map.Entry<Integer, FeedItem> entry : map.entrySet()) { + FeedItem item = entry.getValue(); + queue.add(item); + } } /** |