From 96fe0917e055aa691f8f3a1b3a52a63ce7e29cbf Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Tue, 5 Oct 2021 00:22:04 +0200 Subject: [PATCH] Fix wrong fragment receiving context menu event --- .../danoeh/antennapod/fragment/EpisodesListFragment.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java index 6d63e4ab2..7ea76bb8d 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java @@ -168,10 +168,9 @@ public abstract class EpisodesListFragment extends Fragment { @Override public boolean onContextItemSelected(@NonNull MenuItem item) { Log.d(TAG, "onContextItemSelected() called with: " + "item = [" + item + "]"); - if (!getUserVisibleHint()) { - return false; - } - if (!isVisible()) { + if (!getUserVisibleHint() || !isVisible() || !isMenuVisible()) { + // The method is called on all fragments in a ViewPager, so this needs to be ignored in invisible ones. + // Apparently, none of the visibility check method works reliably on its own, so we just use all. return false; } if (item.getItemId() == R.id.share_item) {