From 75c9d28547b754cb9438b9132f253358487e9123 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 28 Oct 2017 19:05:51 +0200 Subject: [PATCH] make sure the video fragment still exists when the video completes --- .../com/simplemobiletools/gallery/fragments/VideoFragment.kt | 4 ++++ .../simplemobiletools/gallery/fragments/ViewPagerFragment.kt | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index 470e2b986..8985628c1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -464,6 +464,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee } private fun videoCompleted() { + if (!isAdded) { + return + } + if (listener?.videoEnded() == false && context.config.loopVideos) { playVideo() } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt index e495e4168..20a73b886 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt @@ -20,8 +20,9 @@ abstract class ViewPagerFragment : Fragment() { fun getMediumExtendedDetails(medium: Medium): String { val file = File(medium.path) - if (!file.exists()) + if (!file.exists()) { return "" + } val path = "${file.parent.trimEnd('/')}/" val exif = android.media.ExifInterface(medium.path)