Преглед изворни кода

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

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