convert viewpagerfragment to kotlin
This commit is contained in:
parent
aa36c42f13
commit
376089984c
6 changed files with 25 additions and 29 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue