make fragment click listener nullable

This commit is contained in:
Tibor Kaputa 2016-11-18 14:32:53 +01:00
parent 436107be7e
commit 7854f75f22
3 changed files with 7 additions and 3 deletions

View file

@ -66,6 +66,6 @@ class PhotoFragment : ViewPagerFragment(), View.OnClickListener {
if (listener == null) if (listener == null)
listener = activity as ViewPagerFragment.FragmentClickListener listener = activity as ViewPagerFragment.FragmentClickListener
listener.fragmentClicked() listener?.fragmentClicked()
} }
} }

View file

@ -161,7 +161,11 @@ class VideoFragment : ViewPagerFragment(), View.OnClickListener, SurfaceHolder.C
else -> { else -> {
mIsFullscreen = !mIsFullscreen mIsFullscreen = !mIsFullscreen
checkFullscreen() checkFullscreen()
listener.fragmentClicked()
if (listener == null)
listener = activity as ViewPagerFragment.FragmentClickListener
listener?.fragmentClicked()
} }
} }
} }

View file

@ -3,7 +3,7 @@ package com.simplemobiletools.gallery.fragments
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
abstract class ViewPagerFragment : Fragment() { abstract class ViewPagerFragment : Fragment() {
lateinit var listener: FragmentClickListener var listener: FragmentClickListener? = null
abstract fun itemDragged() abstract fun itemDragged()