package com.zswc.creativity.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.zswc.creativity.adapter.RecommedAdapter
import com.zswc.creativity.base.MBFragment
import com.zswc.creativity.databinding.FragmentRecommendBinding
import com.zswc.creativity.model.CollectionList
import com.zswc.creativity.vmodel.RecommendVModel
import com.tencent.mmkv.MMKV
import com.zswc.creativity.databinding.FragmentBlidboxBinding
import com.zswc.creativity.vmodel.BlindBoxVModel

/**
 * 全部
 *Created by shihuiyun
 *on 2020/9/11
 */
class BlindBoxFragment : MBFragment<BlindBoxVModel, FragmentBlidboxBinding>(){


    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)
        //禁止下拉刷新和下拉加载
         binding.recyclerView.overScrollMode= View.OVER_SCROLL_NEVER

          vm.toGetCollectionList()

          vm.list.observe(this, androidx.lifecycle.Observer {
            if (null == it) {
                return@Observer
            }

          //  setAdapter(it)

        })


    }

//    fun setAdapter(list:List<CollectionList>){
//
//       //var adapter=RecommedAdapter()
//        binding.recyclerView.adapter=adapter
//         adapter.addData(list)
//
//        adapter.setOnItemClickListener { adapter, view, position ->
//            var isEnable= MMKV.defaultMMKV().getBoolean("Enable",false)
//            if(isEnable) {
//                //拨打电话
////                launch {
////                    val requestPermissions = PermissionManager.requestPermissions(
////                            this@SpaceDetailActivity, 1000, Manifest.permission.CALL_PHONE
////                    )
////                    if (requestPermissions is PermissionResult.PermissionGranted) {
////                        //拨打电话
////                        vm.bean.value?.fishpond_tel?.let {
////
////                            PopuCallPhoneUtils.show(context(), it, binding.imgCallPhone)
////
////                        }
////                    }
////                }
//            }else{
//                //  toast("抱歉，您未同意用户隐私协议，无法获得相应权限，无法应用该功能")
//
//            }
//        }
//
//
//    }


    override val isRxbus: Boolean
        get() = true

    override fun vmClass(): Class<BlindBoxVModel> {
        return BlindBoxVModel::class.java
    }

    override fun binding(inflater: LayoutInflater, container: ViewGroup?): FragmentBlidboxBinding {
       return  FragmentBlidboxBinding.inflate(layoutInflater)
    }

    override fun title(): String? {
        return null
    }
}
