From 4378c962fc762ad30670d0175781992ce3dd52d9 Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Fri, 23 Oct 2020 13:33:53 +0200 Subject: [PATCH] Bug fix on last image deletion --- .../droidfs/file_viewers/ImageViewer.kt | 22 ++++++++++++++----- app/src/main/res/values/strings.xml | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt index 4dcac12..0ce0c21 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/file_viewers/ImageViewer.kt @@ -124,13 +124,25 @@ class ImageViewer: FileViewerActivity() { } wasMapped = true } - currentMappedImageIndex = if (deltaX < 0){ - MiscUtils.incrementIndex(currentMappedImageIndex, mappedImages) + if (mappedImages.size == 0){ //can happen on deleting images + ColoredAlertDialogBuilder(this) + .keepFullScreen() + .setTitle(R.string.error) + .setCancelable(false) + .setPositiveButton(R.string.ok) { _, _ -> + goBackToExplorer() + } + .setMessage(R.string.no_more_images) + .show() } 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) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 138f957..ebae5b1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -179,4 +179,5 @@ Error cipher is null KeyPermanentlyInvalidatedException It looks like you have added a new fingerprint. Saved passwords hash have become unusable. + No more images found.