Fix wrong fragment receiving context menu event

This commit is contained in:
ByteHamster 2021-10-05 00:22:04 +02:00
parent 160401ad13
commit 96fe0917e0
1 changed files with 3 additions and 4 deletions

View File

@ -168,10 +168,9 @@ public abstract class EpisodesListFragment extends Fragment {
@Override @Override
public boolean onContextItemSelected(@NonNull MenuItem item) { public boolean onContextItemSelected(@NonNull MenuItem item) {
Log.d(TAG, "onContextItemSelected() called with: " + "item = [" + item + "]"); Log.d(TAG, "onContextItemSelected() called with: " + "item = [" + item + "]");
if (!getUserVisibleHint()) { if (!getUserVisibleHint() || !isVisible() || !isMenuVisible()) {
return false; // 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.
if (!isVisible()) {
return false; return false;
} }
if (item.getItemId() == R.id.share_item) { if (item.getItemId() == R.id.share_item) {