Newer
Older
MonCalc / app / src / main / kotlin / jackall / moncalc / adapter / MainFragmentPagerAdapter.kt
package jackall.moncalc.adapter

import android.content.Context
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import jackall.moncalc.R
import jackall.moncalc.fragment.AnalyzeFragment
import jackall.moncalc.fragment.HistoryFragment

/**
 * Created by matsumoto_k on 2017/11/03.
 */
class MainFragmentPagerAdapter(fragmentManager: FragmentManager, val context: Context) : FragmentPagerAdapter(fragmentManager) {
    val pageCount = 2
    val titles = arrayOf(context.resources.getString(R.string.history), context.resources.getString(R.string.analyze))
    override fun getItem(position: Int): Fragment? {
        when (position) {
            0 -> {
                return HistoryFragment()
            }
            1 -> {
                return AnalyzeFragment()
            }
        }
        return null
    }

    override fun getCount(): Int {
        return pageCount
    }

    override fun getPageTitle(position: Int): CharSequence {
        return titles.get(position)
    }
}