convert MyPagerAdapter to kotlin
This commit is contained in:
parent
228ab622e5
commit
5ac4a95531
|
@ -1,39 +0,0 @@
|
|||
package com.simplemobiletools.calendar.adapters;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
|
||||
import com.simplemobiletools.calendar.Constants;
|
||||
import com.simplemobiletools.calendar.fragments.MonthFragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MyPagerAdapter extends FragmentStatePagerAdapter {
|
||||
private final List<String> mCodes;
|
||||
private final MonthFragment.NavigationListener mListener;
|
||||
|
||||
public MyPagerAdapter(FragmentManager fm, List<String> codes, MonthFragment.NavigationListener listener) {
|
||||
super(fm);
|
||||
mCodes = codes;
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mCodes.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
final Bundle bundle = new Bundle();
|
||||
final String code = mCodes.get(position);
|
||||
bundle.putString(Constants.DAY_CODE, code);
|
||||
|
||||
final MonthFragment fragment = new MonthFragment();
|
||||
fragment.setArguments(bundle);
|
||||
fragment.setListener(mListener);
|
||||
return fragment;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.simplemobiletools.calendar.adapters
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.app.FragmentStatePagerAdapter
|
||||
|
||||
import com.simplemobiletools.calendar.Constants
|
||||
import com.simplemobiletools.calendar.fragments.MonthFragment
|
||||
|
||||
class MyPagerAdapter(fm: FragmentManager, private val mCodes: List<String>, private val mListener: MonthFragment.NavigationListener) : FragmentStatePagerAdapter(fm) {
|
||||
|
||||
override fun getCount(): Int {
|
||||
return mCodes.size
|
||||
}
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
val bundle = Bundle()
|
||||
val code = mCodes[position]
|
||||
bundle.putString(Constants.DAY_CODE, code)
|
||||
|
||||
val fragment = MonthFragment()
|
||||
fragment.arguments = bundle
|
||||
fragment.setListener(mListener)
|
||||
return fragment
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue