From e0519e841a5e561a5c98e226f4b4b852bb63b325 Mon Sep 17 00:00:00 2001 From: Philipp Hasper Date: Mon, 28 Aug 2023 08:47:28 +0200 Subject: [PATCH] When deleting image in preview activity, move to the next image Instead of closing the preview after the deletion of an image file, the next image is shown. This allows to conveniently go through a list of images and delete unwanted ones, without the flow being interrupted. Closes #11918 Signed-off-by: Philipp Hasper --- .../android/ui/preview/PreviewImageActivity.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java index 90bf9bce6e..869e92c184 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -232,7 +232,15 @@ public class PreviewImageActivity extends FileActivity implements super.onRemoteOperationFinish(operation, result); if (operation instanceof RemoveFileOperation) { - finish(); + // initialize the pager with the new file list + initViewPager(getUser().get()); + if (mViewPager.getAdapter().getCount() > 0) { + // Trigger page reselection, to update the title + onPageSelected(mViewPager.getCurrentItem()); + } else { + // Last file has been deleted, so finish the activity + finish(); + } } else if (operation instanceof SynchronizeFileOperation) { onSynchronizeFileOperationFinish(result); }