diff options
author | Tom Hennen <tom.hennen@gmail.com> | 2013-09-09 21:29:53 -0400 |
---|---|---|
committer | Tom Hennen <tom.hennen@gmail.com> | 2013-09-09 21:29:53 -0400 |
commit | e1fc800d088a4b150deb3aff072cda7af8da8ca7 (patch) | |
tree | 0c1073fda0016ab017195d6dd18edb002983e896 /src/de | |
parent | 34a5e62339928d9a6353ba966cf9841e1719b570 (diff) | |
download | AntennaPod-e1fc800d088a4b150deb3aff072cda7af8da8ca7.zip |
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.
Diffstat (limited to 'src/de')
-rw-r--r-- | src/de/danoeh/antennapod/fragment/EpisodesFragment.java | 38 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java | 6 |
2 files changed, 37 insertions, 7 deletions
diff --git a/src/de/danoeh/antennapod/fragment/EpisodesFragment.java b/src/de/danoeh/antennapod/fragment/EpisodesFragment.java index a99056c9a..6b228662f 100644 --- a/src/de/danoeh/antennapod/fragment/EpisodesFragment.java +++ b/src/de/danoeh/antennapod/fragment/EpisodesFragment.java @@ -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()) { diff --git a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java index aad240fc7..e99a733dc 100644 --- a/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java +++ b/src/de/danoeh/antennapod/util/menuhandler/FeedItemMenuHandler.java @@ -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)); |