diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java index 55dd03646..0525460d9 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java @@ -183,9 +183,9 @@ public class VideoFragment extends ViewPagerFragment mIsFullscreen = !mIsFullscreen; checkFullscreen(); - if (mListener == null) - mListener = (FragmentClickListener) getActivity(); - mListener.fragmentClicked(); + if (getListener() == null) + setListener((FragmentClickListener) getActivity()); + getListener().fragmentClicked(); break; } } diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java deleted file mode 100644 index 0e46e301f..000000000 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/ViewPagerFragment.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.simplemobiletools.gallery.fragments; - -import android.support.v4.app.Fragment; - -public abstract class ViewPagerFragment extends Fragment { - protected FragmentClickListener mListener; - - public void setListener(FragmentClickListener listener) { - mListener = listener; - } - - public abstract void itemDragged(); - - public abstract void systemUiVisibilityChanged(boolean toFullscreen); - - public abstract void updateItem(); - - public interface FragmentClickListener { - void fragmentClicked(); - } -} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index 0c2e26cea..e7490878d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -39,7 +39,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic if (savedInstanceState == null) { mFragment = if (mIsVideo) VideoFragment() else PhotoFragment() - mFragment!!.setListener(this) + mFragment!!.listener = this mFragment!!.arguments = bundle supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, mFragment).commit() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt index d207c659e..14839006e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MyPagerAdapter.kt @@ -37,7 +37,7 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m mFragments.put(position, fragment) fragment.arguments = bundle - fragment.setListener(activity) + fragment.listener = activity return fragment } 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 a6359e2c3..186bb1a9f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -63,9 +63,9 @@ class PhotoFragment : ViewPagerFragment(), View.OnClickListener { } private fun photoClicked() { - if (mListener == null) - mListener = activity as ViewPagerFragment.FragmentClickListener + if (listener == null) + listener = activity as ViewPagerFragment.FragmentClickListener - mListener.fragmentClicked() + 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 new file mode 100644 index 000000000..5ad715668 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/ViewPagerFragment.kt @@ -0,0 +1,17 @@ +package com.simplemobiletools.gallery.fragments + +import android.support.v4.app.Fragment + +abstract class ViewPagerFragment : Fragment() { + lateinit var listener: FragmentClickListener + + abstract fun itemDragged() + + abstract fun systemUiVisibilityChanged(toFullscreen: Boolean) + + abstract fun updateItem() + + interface FragmentClickListener { + fun fragmentClicked() + } +}