diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index db6c9fd27..c8154e76a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -66,6 +66,6 @@ class PhotoFragment : ViewPagerFragment(), View.OnClickListener { if (listener == null) listener = activity as ViewPagerFragment.FragmentClickListener - listener.fragmentClicked() + listener?.fragmentClicked() } } 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 6c1f9070c..b99a94cf9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -161,7 +161,11 @@ class VideoFragment : ViewPagerFragment(), View.OnClickListener, SurfaceHolder.C else -> { mIsFullscreen = !mIsFullscreen checkFullscreen() - listener.fragmentClicked() + + if (listener == null) + listener = activity as ViewPagerFragment.FragmentClickListener + + listener?.fragmentClicked() } } } 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 5ad715668..0fcdd8607 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt @@ -3,7 +3,7 @@ package com.simplemobiletools.gallery.fragments import android.support.v4.app.Fragment abstract class ViewPagerFragment : Fragment() { - lateinit var listener: FragmentClickListener + var listener: FragmentClickListener? = null abstract fun itemDragged()