summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2013-08-29 11:39:40 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2013-08-29 11:39:40 +0200
commitad98592608e2981bed8ccf56bb7e22ce2019a6fd (patch)
tree0619c363e558640e97aab69bf50e216b57beb218 /src
parentfb1d348e282c13fd9a78702af7cd1303c940252f (diff)
parentb886c38308a4e7ff9ab733e52b3703962d789fbf (diff)
downloadAntennaPod-ad98592608e2981bed8ccf56bb7e22ce2019a6fd.zip
Merge branch 'move-to-top' of git://github.com/TomHennen/AntennaPod into TomHennen-move-to-top
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));