From 4b2d41ec7526a6c1c0f103b2cdf9640d03ce85bc Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 7 Jan 2018 16:57:04 +0100 Subject: [PATCH] fix #555, check if file exists at viewpager activity --- app/build.gradle | 2 +- .../gallery/activities/ViewPagerActivity.kt | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ee5ef2f0c..571e93fd2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,7 +42,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.5.11' + implementation 'com.simplemobiletools:commons:3.6.0' implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.9.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0' implementation 'com.android.support:multidex:1.0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 84fd594f8..42c9534bb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -177,6 +177,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return } + val file = File(mPath) + if (!file.exists()) { + deleteFromMediaStore(file) + finish() + return + } + if (intent.extras?.containsKey(IS_VIEW_INTENT) == true) { if (isShowHiddenFlagNeeded()) { if (!config.isPasswordProtectionOn) { @@ -189,7 +196,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View showSystemUI() - mDirectory = File(mPath).parent + mDirectory = file.parent supportActionBar?.title = mPath.getFilenameFromPath() view_pager.onGlobalLayout {