summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/feed
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2013-02-18 19:11:33 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2013-02-18 19:11:33 +0100
commitef50c412c94bcff92ba88149d94e3e2449725cc4 (patch)
tree888869b63ddafbb10f05c9ae798f9ffbb6b6bd6d /src/de/danoeh/antennapod/feed
parent89d4bdc9c6c000632d42fe548f1dedaa4c6dbd05 (diff)
downloadAntennaPod-ef50c412c94bcff92ba88149d94e3e2449725cc4.zip
Implemented drag & drop reordering
Diffstat (limited to 'src/de/danoeh/antennapod/feed')
-rw-r--r--src/de/danoeh/antennapod/feed/FeedManager.java34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java
index 3e5e838b0..6c3471e5c 100644
--- a/src/de/danoeh/antennapod/feed/FeedManager.java
+++ b/src/de/danoeh/antennapod/feed/FeedManager.java
@@ -765,16 +765,29 @@ public class FeedManager {
}
}
- public void moveQueueItem(final Context context, FeedItem item, int delta) {
+ /**
+ * Moves the queue item at the specified index to another position. If the
+ * indices are out of range, no operation will be performed.
+ *
+ * @param from
+ * index of the item that is going to be moved
+ * @param to
+ * destination index of item
+ * @param broadcastUpdate
+ * true if the method should send a queue update broadcast after
+ * the operation has been performed. This should be set to false
+ * if the order of the queue is changed through drag & drop
+ * reordering to avoid visual glitches.
+ */
+ public void moveQueueItem(final Context context, int from, int to,
+ boolean broadcastUpdate) {
if (AppConfig.DEBUG)
- Log.d(TAG, "Moving queue item");
- int itemIndex = queue.indexOf(item);
- int newIndex = itemIndex + delta;
- if (newIndex >= 0 && newIndex < queue.size()) {
- FeedItem oldItem = queue.set(newIndex, item);
- queue.set(itemIndex, oldItem);
+ Log.d(TAG, "Moving queue item from index " + from + " to index "
+ + to);
+ if (from >= 0 && from < queue.size() && to >= 0 && to < queue.size()) {
+ FeedItem item = queue.remove(from);
+ queue.add(to, item);
dbExec.execute(new Runnable() {
-
@Override
public void run() {
PodDBAdapter adapter = new PodDBAdapter(context);
@@ -783,9 +796,10 @@ public class FeedManager {
adapter.close();
}
});
-
+ if (broadcastUpdate) {
+ sendQueueUpdateBroadcast(context, item);
+ }
}
- sendQueueUpdateBroadcast(context, item);
}
public boolean isInQueue(FeedItem item) {