Skip to content

Commit 092cea0

Browse files
committed
fix: prevent crash on page selection when image list from adapter is empty
1 parent 3caa33f commit 092cea0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @author Juan Carlos Garrote Gascón
99
* @author Jorge Aguado Recio
1010
*
11-
* Copyright (C) 2024 ownCloud GmbH.
11+
* Copyright (C) 2025 ownCloud GmbH.
1212
*
1313
*
1414
* This program is free software: you can redistribute it and/or modify
@@ -301,10 +301,14 @@ class PreviewImageActivity : FileActivity(),
301301
if (operationsServiceBinder != null) {
302302
savedPosition = position
303303
hasSavedPosition = true
304-
val currentFile = previewImagePagerAdapter.getFileAt(position)
305-
updateActionBarTitle(currentFile.fileName)
306-
if (!previewImagePagerAdapter.pendingErrorAt(position)) {
307-
fileOperationsViewModel.performOperation(FileOperation.SynchronizeFileOperation(currentFile, account.name))
304+
if (previewImagePagerAdapter.count != 0) {
305+
val currentFile = previewImagePagerAdapter.getFileAt(position)
306+
updateActionBarTitle(currentFile.fileName)
307+
if (!previewImagePagerAdapter.pendingErrorAt(position)) {
308+
fileOperationsViewModel.performOperation(FileOperation.SynchronizeFileOperation(currentFile, account.name))
309+
}
310+
} else {
311+
backToDisplayActivity()
308312
}
309313

310314
// Call to reset image zoom to initial state

0 commit comments

Comments
 (0)