convert MyPagerAdapter to kotlin

This commit is contained in:
tibbi 2016-09-16 22:43:07 +02:00
parent 228ab622e5
commit 5ac4a95531
2 changed files with 27 additions and 39 deletions

View File

@ -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;
}
}

View File

@ -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
}
}