package com.mints.goodmoney.ui.adapter

import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.PagerAdapter

class FriendsPagerAdapter(recyList: MutableList<RecyclerView>)
    : PagerAdapter() {

    private val mRecyList: MutableList<RecyclerView> = recyList

    override fun getItemPosition(`object`: Any): Int {
        // 处理notify方法失效
        return POSITION_NONE
    }

    override fun getCount() = 2

    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        return view === `object`
    }

    override fun instantiateItem(container: ViewGroup, position: Int): Any {
        val recyclerView = mRecyList[position]
        container.addView(mRecyList[position])
        return recyclerView
    }

    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        container.removeView(`object` as View?)
    }

    override fun getPageTitle(position: Int): CharSequence? {
        return if (position == 0) {
            "昨日贡献榜"
        } else {
            "今日收益榜"
        }
    }
}