package com.lukouguoji.gnj.activity

import android.os.Bundle
import android.view.View
import android.widget.*
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import com.alibaba.android.arouter.facade.annotation.Route
import com.lukouguoji.gnj.R
import com.lukouguoji.gnj.adapt.GnjYiKuListSwitchAdapter
import com.lukouguoji.gnj.fragment.GnjYiKu2Fragment
import com.lukouguoji.gnj.fragment.GnjYiKuFragment
import com.lukouguoji.module_base.BaseActivity
import com.lukouguoji.module_base.router.ARouterConstants

@Route(path = ARouterConstants.ACTIVITY_URL_GNJ_YI_KU)
class GnjYiKuListActivity : BaseActivity(), View.OnClickListener {

    private fun initView() {
        val listFragment = arrayListOf<Fragment>()
        listFragment.add(GnjYiKu2Fragment())
        listFragment.add(GnjYiKuFragment())
        val viewPager2 = findViewById<ViewPager2>(R.id.viewpager2)
        val viewPagerAdapter = GnjYiKuListSwitchAdapter(listFragment, supportFragmentManager, lifecycle)
        viewPager2.adapter = viewPagerAdapter
        viewPager2.setCurrentItem(1, false)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_gnj_yi_ku_list)
        initView()
    }

    override fun onClick(v: View?) {
        v?.let {
            when (it.id) {
                else -> {
                    Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
                }
            }
        }
    }
}