From b4f8773d7bf540ea39f038e41ffc8bbeb2daa570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Brey?= Date: Wed, 19 Oct 2022 16:25:24 +0200 Subject: [PATCH] Fix crash in GalleryFragment when menu button is double-tapped MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Brey --- .../owncloud/android/ui/fragment/GalleryFragment.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java index cf54357db5..fab83dd2f8 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java @@ -61,6 +61,8 @@ import androidx.recyclerview.widget.RecyclerView; */ public class GalleryFragment extends OCFileListFragment implements GalleryFragmentBottomSheetActions { private static final int MAX_ITEMS_PER_ROW = 10; + private static final String FRAGMENT_TAG_BOTTOM_SHEET = "data"; + private boolean photoSearchQueryRunning = false; private AsyncTask photoSearchTask; private long startDate; @@ -282,12 +284,18 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme // Handle item selection if (item.getItemId() == R.id.action_three_dot_icon && !photoSearchQueryRunning && galleryFragmentBottomSheetDialog != null) { - galleryFragmentBottomSheetDialog.show(getChildFragmentManager(),"data" ); + showBottomSheet(); return true; } return super.onOptionsItemSelected(item); } + private void showBottomSheet() { + if (!galleryFragmentBottomSheetDialog.isVisible()) { + galleryFragmentBottomSheetDialog.show(getChildFragmentManager(), FRAGMENT_TAG_BOTTOM_SHEET); + } + } + @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (requestCode == SELECT_LOCATION_REQUEST_CODE && data != null) {