浏览代码

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 <vcs@hasper.info>
Philipp Hasper 1 年之前
父节点
当前提交
e0519e841a
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      app/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java

+ 9 - 1
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);
         }