Moved move to top/bottom menu options to EpisodesFragement from FeedItemMenuHandler so that we can ensure the user was actually in the 'Queue' dropdown when they opened the menu. Also, move to top now only shows up if the item isn't already at the top, similarly, for move to bottom, it only shows up if the item isn't already at the bottom.
This commit is contained in:
parent
34a5e62339
commit
e1fc800d08
|
@ -67,15 +67,5 @@
|
|||
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>
|
|
@ -15,6 +15,8 @@
|
|||
<item name="organize_queue_item" type="id"/>
|
||||
<item name="drag_handle" type="id"/>
|
||||
<item name="skip_episode_item" type="id"/>
|
||||
<item name="move_to_top_item" type="id"/>
|
||||
<item name="move_to_bottom_item" type="id"/>
|
||||
<item name="image_disk_cache_key" type="id"/>
|
||||
<item name="imageloader_key" type="id"/>
|
||||
<item name="notification_gpodnet_sync_error" type="id"/>
|
||||
|
|
|
@ -222,6 +222,12 @@ public class EpisodesFragment extends Fragment {
|
|||
}
|
||||
}, selectedItem, false, QueueAccess.ItemListAccess(queue));
|
||||
|
||||
// check to see if the item is in the queue, if so add queue menu items
|
||||
int itemIndex = queue.indexOf(selectedItem);
|
||||
if (itemIndex != -1) {
|
||||
addQueueOnlyMenus(menu, itemIndex);
|
||||
}
|
||||
|
||||
} else if (selectedGroupId == ExternalEpisodesListAdapter.GROUP_POS_QUEUE) {
|
||||
menu.add(Menu.NONE, R.id.organize_queue_item, Menu.NONE,
|
||||
R.string.organize_queue_label);
|
||||
|
@ -237,6 +243,24 @@ public class EpisodesFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds submenus to the ContextMenu if the item selected is in the queue.
|
||||
* @param menu the ContextMenu to add the submenus to
|
||||
* @param itemIndex the index of the selected item within the queue.
|
||||
*/
|
||||
private void addQueueOnlyMenus(ContextMenu menu, int itemIndex) {
|
||||
if (itemIndex != 0) {
|
||||
// don't add move to top if this item is already on the top
|
||||
menu.add(Menu.NONE, R.id.move_to_top_item, Menu.NONE, getActivity()
|
||||
.getString(R.string.move_to_top_label));
|
||||
}
|
||||
if (itemIndex != queue.size() - 1) {
|
||||
// don't add move to bottom if this item is already on the bottom
|
||||
menu.add(Menu.NONE, R.id.move_to_bottom_item, Menu.NONE, getActivity()
|
||||
.getString(R.string.move_to_bottom_label));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(android.view.MenuItem item) {
|
||||
boolean handled = false;
|
||||
|
@ -249,7 +273,19 @@ public class EpisodesFragment extends Fragment {
|
|||
DownloadRequestErrorDialogCreator.newRequestErrorDialog(
|
||||
getActivity(), e.getMessage());
|
||||
}
|
||||
|
||||
if (!handled) {
|
||||
// if it wasn't handled by the FeedItemMenuHandler it might be one of ours
|
||||
switch (item.getItemId()) {
|
||||
case R.id.move_to_top_item:
|
||||
DBWriter.moveQueueItemToTop(getActivity(), selectedItem.getId(), true);
|
||||
handled = true;
|
||||
break;
|
||||
case R.id.move_to_bottom_item:
|
||||
DBWriter.moveQueueItemToBottom(getActivity(), selectedItem.getId(), true);
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (selectedGroupId == ExternalEpisodesListAdapter.GROUP_POS_QUEUE) {
|
||||
handled = true;
|
||||
switch (item.getItemId()) {
|
||||
|
|
|
@ -153,12 +153,6 @@ 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));
|
||||
|
|
Loading…
Reference in New Issue