Merge branch 'move-to-top' of git://github.com/TomHennen/AntennaPod into TomHennen-move-to-top

This commit is contained in:
daniel oeh 2013-08-29 11:39:40 +02:00
commit ad98592608
4 changed files with 61 additions and 2 deletions

View File

@ -67,6 +67,15 @@
android:showAsAction="collapseActionView"
android:title="@string/support_label">
</item>
<item
android:id="@+id/move_to_top_item"
android:showAsAction="collapseActionView"
android:title="@string/move_to_top_label">
</item>
<item
android:id="@+id/move_to_bottom_item"
android:showAsAction="collapseActionView"
android:title="@string/move_to_bottom_label">
</item>
</menu>

View File

@ -129,6 +129,8 @@
<string name="organize_queue_label">Organize queue</string>
<string name="undo">Undo</string>
<string name="removed_from_queue">Item removed</string>
<string name="move_to_top_label">Move to top</string>
<string name="move_to_bottom_label">Move to bottom</string>
<!-- Flattr -->
<string name="flattr_auth_label">Flattr sign-in</string>

View File

@ -460,6 +460,48 @@ 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.
*

View File

@ -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));