From d0c011a17a374b594430ac59152ad4d0c69a5ad6 Mon Sep 17 00:00:00 2001 From: k3b <1374583+k3b@users.noreply.github.com> Date: Fri, 3 Jan 2020 21:53:12 +0100 Subject: [PATCH] #155: Gallery refresh query after detail-change or delete --- .../gallery/cursor/GalleryCursorFragment.java | 4 ++-- .../imagedetail/ImageDetailActivityViewPager.java | 2 +- .../java/de/k3b/android/util/AndroidFileCommands.java | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/gallery/cursor/GalleryCursorFragment.java b/app/src/main/java/de/k3b/android/androFotoFinder/gallery/cursor/GalleryCursorFragment.java index 0d490aca..e3d5d693 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/gallery/cursor/GalleryCursorFragment.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/gallery/cursor/GalleryCursorFragment.java @@ -438,7 +438,7 @@ public void onResume() { // workaround fragment lifecycle is newFragment.attach oldFragment.detach. // this makes shure that the visible fragment has commands MoveOrCopyDestDirPicker.sFileCommands = mFileCommands; - + requeryIfDataHasChanged(); } /** @@ -835,7 +835,7 @@ public boolean onOptionsItemSelected(MenuItem menuItem) { AndroidFileCommands fileCommands = mFileCommands; final SelectedFiles selectedFiles = this.mAdapter.createSelectedFiles(getActivity(), this.mSelectedItems); - if ((mSelectedItems != null) && (fileCommands.onOptionsItemSelected(menuItem, selectedFiles))) { + if ((mSelectedItems != null) && (fileCommands.onOptionsItemSelected(menuItem, selectedFiles, this))) { return true; } switch (menuItem.getItemId()) { diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailActivityViewPager.java b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailActivityViewPager.java index e7f72f3d..52553ef0 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailActivityViewPager.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailActivityViewPager.java @@ -207,7 +207,7 @@ public boolean onOptionsItemSelected(MenuItem menuItem) { this.invalidateOptionsMenu(); return true; } - if (mFileCommands.onOptionsItemSelected(menuItem, getCurrentFoto())) { + if (mFileCommands.onOptionsItemSelected(menuItem, getCurrentFoto(), this)) { mModifyCount++; } else { // Handle presses on the action bar items diff --git a/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java b/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java index ea7c1f46..8d001f99 100644 --- a/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java +++ b/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java @@ -173,12 +173,12 @@ private static int getResourceId(int opCode) { } - public boolean onOptionsItemSelected(final MenuItem item, final SelectedFiles selectedFileNames) { + public boolean onOptionsItemSelected(final MenuItem item, final SelectedFiles selectedFileNames, DataChangeNotifyer.DataChangedListener dataChangedListener) { if ((selectedFileNames != null) && (selectedFileNames.size() > 0)) { // Handle item selection switch (item.getItemId()) { case R.id.cmd_delete: - return cmdDeleteFileWithQuestion(selectedFileNames); + return cmdDeleteFileWithQuestion(selectedFileNames, dataChangedListener); default:break; } } @@ -276,7 +276,8 @@ private void setLastCopyToPath(String copyToPath) { edit.apply(); } - public boolean cmdDeleteFileWithQuestion(final SelectedFiles fotos) { + public boolean cmdDeleteFileWithQuestion(final SelectedFiles fotos, + final DataChangeNotifyer.DataChangedListener dataChangedListener) { String[] pathNames = fotos.getFileNames(); String errorMessage = checkWriteProtected(R.string.delete_menu_title, SelectedFiles.getFiles(pathNames)); @@ -307,6 +308,9 @@ public void onClick( final int id) { mActiveAlert = null; deleteFiles(fotos, null); + if (dataChangedListener != null) { + dataChangedListener.onNotifyDataChanged(); + } } } )