diff options
author | ByteHamster <info@bytehamster.com> | 2021-03-05 11:26:08 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2021-03-05 11:26:08 +0100 |
commit | 4b7cb20a7aa95c52eadb034ff91c9376e347997f (patch) | |
tree | b5a3944d100fac167ee344c087f93fa70a7ebda6 /app/src | |
parent | d1d5974cea24e90d2a6c7f211f8f0851b134bf34 (diff) | |
download | AntennaPod-4b7cb20a7aa95c52eadb034ff91c9376e347997f.zip |
Fixed long-pressing items on subscriptions page
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java | 4 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java | 35 |
2 files changed, 11 insertions, 28 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java index 1d85cdaff..660302d56 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java @@ -30,10 +30,6 @@ import jp.shts.android.library.TriangleLabelView; * Adapter for subscriptions */ public class SubscriptionsAdapter extends BaseAdapter implements AdapterView.OnItemClickListener { - - /** placeholder object that indicates item should be added */ - public static final Object ADD_ITEM_OBJ = new Object(); - /** the position in the view that holds the add item; 0 is the first, -1 is the last position */ private static final String TAG = "SubscriptionsAdapter"; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java index 3c529d941..c9f85b22e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java @@ -86,7 +86,7 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem private TextView feedsFilteredMsg; private Toolbar toolbar; - private int mPosition = -1; + private Feed selectedFeed = null; private boolean isUpdatingFeeds = false; private boolean displayUpArrow; @@ -265,37 +265,24 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem AdapterView.AdapterContextMenuInfo adapterInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; int position = adapterInfo.position; - Object selectedObject = subscriptionAdapter.getItem(position); - if (selectedObject.equals(SubscriptionsAdapter.ADD_ITEM_OBJ)) { - mPosition = position; - return; - } - - Feed feed = (Feed) selectedObject; - - MenuInflater inflater = requireActivity().getMenuInflater(); - inflater.inflate(R.menu.nav_feed_context, menu); - - menu.setHeaderTitle(feed.getTitle()); + NavDrawerData.DrawerItem selectedObject = (NavDrawerData.DrawerItem) subscriptionAdapter.getItem(position); - mPosition = position; + if (selectedObject.type == NavDrawerData.DrawerItem.Type.FEED) { + MenuInflater inflater = requireActivity().getMenuInflater(); + inflater.inflate(R.menu.nav_feed_context, menu); + selectedFeed = ((NavDrawerData.FeedDrawerItem) selectedObject).feed; + } + menu.setHeaderTitle(selectedObject.getTitle()); } @Override public boolean onContextItemSelected(MenuItem item) { - final int position = mPosition; - mPosition = -1; // reset - if (position < 0) { - return false; - } - - Object selectedObject = subscriptionAdapter.getItem(position); - if (selectedObject.equals(SubscriptionsAdapter.ADD_ITEM_OBJ)) { - // this is the add object, do nothing + if (selectedFeed == null) { return false; } - Feed feed = (Feed) selectedObject; + Feed feed = selectedFeed; + selectedFeed = null; switch (item.getItemId()) { case R.id.remove_all_new_flags_item: displayConfirmationDialog( |