package com.zxhl.main.page.fragment

import android.util.Log
import android.view.FrameMetrics
import android.view.View
import androidx.fragment.app.Fragment
import com.flyco.tablayout.listener.CustomTabEntity
import com.zxhl.cms.common.base.BaseFragment
import com.zxhl.main.R
import com.zxhl.main.page.view.BaseViewPagerFragment
import com.zxhl.main.page.view.TabEntity


class HomeFragment: BaseViewPagerFragment() {
    override val createTitles = ArrayList<CustomTabEntity>().apply {
        add(TabEntity("Popular"))
        add(TabEntity("Hot",R.drawable.icon_fire,R.drawable.icon_fire))

    }

    override val createFragments: Array<Fragment> = arrayOf(
        PopularFragment.newInstance(),
        HotFragment.newInstance()
    )

    override fun layoutID(): Int {

        return R.layout.fragment_layout_home
    }

    override fun init(view: View?) {
        viewPager?.currentItem = 0
    }

    override fun lazyLoad() {
        super.lazyLoad()
        if (isVisible && isInitial) {
            createFragments[viewPager?.currentItem ?: 0].userVisibleHint = true
        }
    }

    override fun onDestroy() {
        super.onDestroy()


    }

    companion object {

        fun newInstance() = HomeFragment()
    }
}