Merge pull request #5445 from ByteHamster/fix-context-menu

Fix wrong fragment receiving context menu event
This commit is contained in:
ByteHamster 2021-10-05 20:53:45 +02:00 committed by GitHub
commit bb36cfef63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {