summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/de/danoeh/antennapod/storage/DBWriter.java44
-rw-r--r--src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java6
2 files changed, 49 insertions, 1 deletions
diff --git a/src/de/danoeh/antennapod/storage/DBWriter.java b/src/de/danoeh/antennapod/storage/DBWriter.java
index d96299dbe..d60c3e5b8 100644
--- a/src/de/danoeh/antennapod/storage/DBWriter.java
+++ b/src/de/danoeh/antennapod/storage/DBWriter.java
@@ -459,7 +459,49 @@ public class DBWriter {
});
}
-
+
+ /**
+ * Moves the specified item to the top of the queue.
+ *
+ * @param context A context that is used for opening a database connection.
+ * @param selectedItem The item to move to the top of the queue
+ * @param broadcastUpdate true if this operation should trigger a QueueUpdateBroadcast. This option should be set to
+ * false if the caller wants to avoid unexpected updates of the GUI.
+ */
+ public static Future<?> moveQueueItemToTop(final Context context, final long itemId, final boolean broadcastUpdate) {
+ List<Long> queueIdList = DBReader.getQueueIDList(context);
+ int currentLocation = 0;
+ for (long id : queueIdList) {
+ if (id == itemId) {
+ return moveQueueItem(context, currentLocation, 0, true);
+ }
+ currentLocation++;
+ }
+ Log.e(TAG, "moveQueueItemToTop: item not found");
+ return null;
+ }
+
+ /**
+ * Moves the specified item to the bottom of the queue.
+ *
+ * @param context A context that is used for opening a database connection.
+ * @param selectedItem The item to move to the bottom of the queue
+ * @param broadcastUpdate true if this operation should trigger a QueueUpdateBroadcast. This option should be set to
+ * false if the caller wants to avoid unexpected updates of the GUI.
+ */
+ public static Future<?> moveQueueItemToBottom(final Context context, final long itemId, final boolean broadcastUpdate) {
+ List<Long> queueIdList = DBReader.getQueueIDList(context);
+ int currentLocation = 0;
+ for (long id : queueIdList) {
+ if (id == itemId) {
+ return moveQueueItem(context, currentLocation, queueIdList.size() - 1, true);
+ }
+ currentLocation++;
+ }
+ Log.e(TAG, "moveQueueItemToBottom: item not found");
+ return null;
+ }
+
/**
* Changes the position of a FeedItem in the queue.
*
diff --git a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java
index fdd2011ae..7856422ba 100644
--- a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java
+++ b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java
@@ -153,6 +153,12 @@ public class FeedItemMenuHandler {
DBTasks.playMedia(context, selectedItem.getMedia(), true, true,
true);
break;
+ case R.id.move_to_top_item:
+ DBWriter.moveQueueItemToTop(context, selectedItem.getId(), true);
+ break;
+ case R.id.move_to_bottom_item:
+ DBWriter.moveQueueItemToBottom(context, selectedItem.getId(), true);
+ break;
case R.id.visit_website_item:
Uri uri = Uri.parse(selectedItem.getLink());
context.startActivity(new Intent(Intent.ACTION_VIEW, uri));