package com.zxbw.modulemain.activity

import android.text.TextUtils
import android.util.Log
import android.view.View
import com.zxbw.modulemain.R
import com.zxbw.modulemain.fragment.MagicBoxOrderFragment
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.FragmentAdapter
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.common.base.BaseFragment

import kotlinx.android.synthetic.main.activity_layout_my_order.*


//我的订单
class MyOrderActivity : BaseActivity() {
    var type:String?=""
    val createTitles = ArrayList<String>().apply {
        //add(AppContext.get().getString(R.string.shop_order))
        add(AppContext.get().getString(R.string.magic_box_order))
    }

    val createFragments: Array<BaseFragment> = arrayOf(
       // ShopOrderListFragment.newInstance(),
        MagicBoxOrderFragment.newInstance()
    )
    override fun onClick(v: View?) {

    }

    override fun before() {
        super.before()
        setStatusBarBackground(AppContext.get().resources.getColor(R.color.transparent))
    }

    override fun layoutID(): Int {
        return R.layout.activity_layout_my_order
    }

    override fun init() {
        type = intent?.data?.getQueryParameter("type") ?: ""
        Log.e("MXL","type:"+type)
        initVeiwPager()
        id_img_back?.setOnClickListener {
            finish()
        }



    }

    fun initVeiwPager() {
        val adapter = FragmentAdapter(supportFragmentManager)
        order_viewPager?.adapter = adapter

        for (i in createFragments.indices) {
            adapter?.addFrag(createFragments[i], createTitles[i])
        }
        adapter?.notifyDataSetChanged()
        id_fragment_order_tab?.setViewPager(order_viewPager)
        id_fragment_order_tab?.overScrollMode = View.OVER_SCROLL_NEVER
        if(TextUtils.equals(type,"1")){
            order_viewPager?.currentItem=1
        }
    }

    override fun onDestroy() {
        super.onDestroy()
    }

}