Bug fix on last image deletion

This commit is contained in:
Matéo Duparc 2020-10-23 13:33:53 +02:00
parent e5413653d0
commit 4378c962fc
2 changed files with 18 additions and 5 deletions

View File

@ -124,13 +124,25 @@ class ImageViewer: FileViewerActivity() {
} }
wasMapped = true wasMapped = true
} }
currentMappedImageIndex = if (deltaX < 0){ if (mappedImages.size == 0){ //can happen on deleting images
MiscUtils.incrementIndex(currentMappedImageIndex, mappedImages) ColoredAlertDialogBuilder(this)
.keepFullScreen()
.setTitle(R.string.error)
.setCancelable(false)
.setPositiveButton(R.string.ok) { _, _ ->
goBackToExplorer()
}
.setMessage(R.string.no_more_images)
.show()
} else { } else {
MiscUtils.decrementIndex(currentMappedImageIndex, mappedImages) currentMappedImageIndex = if (deltaX < 0){
MiscUtils.incrementIndex(currentMappedImageIndex, mappedImages)
} else {
MiscUtils.decrementIndex(currentMappedImageIndex, mappedImages)
}
filePath = mappedImages[currentMappedImageIndex].fullPath
loadImage()
} }
filePath = mappedImages[currentMappedImageIndex].fullPath
loadImage()
} }
fun onClickDelete(view: View) { fun onClickDelete(view: View) {

View File

@ -179,4 +179,5 @@
<string name="error_cipher_null">Error cipher is null</string> <string name="error_cipher_null">Error cipher is null</string>
<string name="key_permanently_invalidated_exception">KeyPermanentlyInvalidatedException</string> <string name="key_permanently_invalidated_exception">KeyPermanentlyInvalidatedException</string>
<string name="key_permanently_invalidated_exception_msg">It looks like you have added a new fingerprint. Saved passwords hash have become unusable.</string> <string name="key_permanently_invalidated_exception_msg">It looks like you have added a new fingerprint. Saved passwords hash have become unusable.</string>
<string name="no_more_images">No more images found.</string>
</resources> </resources>