//package com.gh.gamecenter.personalhome.home
//
//import android.os.Bundle
//import android.view.View
//import androidx.core.content.ContextCompat
//import androidx.core.os.bundleOf
//import androidx.recyclerview.widget.GridLayoutManager
//import androidx.recyclerview.widget.RecyclerView
//import com.gh.gamecenter.common.utils.dip2px
//import com.gh.gamecenter.common.utils.viewModelProvider
//import com.gh.gamecenter.common.view.FixGridLayoutManager
//import com.gh.gamecenter.common.view.GridSpacingItemDecoration
//import com.gh.gamecenter.R
//import com.gh.gamecenter.common.baselist.ListAdapter
//import com.gh.gamecenter.common.baselist.ListFragment
//import com.gh.gamecenter.entity.PersonalEntity
//import com.gh.gamecenter.entity.PersonalHistoryEntity
//import com.halo.assistant.HaloApp
//import kotlinx.android.synthetic.main.fragment_user_history.*
//
//class UserVideoHistoryFragment : ListFragment<PersonalHistoryEntity, UserVideoHistoryViewModel>() {
//
//    private var mCount = PersonalEntity.Count()
//    private var mUserId: String = ""
//
//    private var mAdapter: UserVideoHistoryAdapter? = null
//    private lateinit var mViewModel: UserVideoHistoryViewModel
//
//    override fun getLayoutId(): Int {
//        return R.layout.fragment_user_history
//    }
//
//    override fun onCreate(savedInstanceState: Bundle?) {
//        arguments?.apply {
//            mUserId = getString(USER_ID, "")
//            mCount = getParcelable(COUNT) ?: PersonalEntity.Count()
//        }
//        super.onCreate(savedInstanceState)
//    }
//
//    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
//        super.onViewCreated(view, savedInstanceState)
//
//        filterHint.text = "全部视频（${mCount.video}）"
//        filterContainer.visibility = View.INVISIBLE
//
//        val gridLayoutManager = FixGridLayoutManager(requireContext(), 2)
//        gridLayoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
//            override fun getSpanSize(position: Int): Int {
//                return if (position == mAdapter!!.itemCount - 1) {
//                    2
//                } else {
//                    1
//                }
//            }
//        }
//        mListRv.layoutManager = gridLayoutManager
//        mListRv.setPadding(8F.dip2px(), 0, 8F.dip2px(), 0)
//        filter.setPadding(8F.dip2px(), 0, 8F.dip2px(), 0)
//        filterContainer.setPadding(0, 10F.dip2px(), 0, 10F.dip2px())
//    }
//
//    override fun getItemDecoration(): RecyclerView.ItemDecoration? {
//        return GridSpacingItemDecoration(2, 8F.dip2px(), false)
//    }
//
//    override fun provideListViewModel(): UserVideoHistoryViewModel {
//        mViewModel = viewModelProvider(UserVideoHistoryViewModel.Factory(HaloApp.getInstance().application, mUserId))
//
//        return mViewModel
//    }
//
//    override fun provideListAdapter(): ListAdapter<*> {
//        if (mAdapter == null) {
//            mAdapter = UserVideoHistoryAdapter(requireContext(), mListViewModel)
//        }
//        return mAdapter!!
//    }
//
//    override fun onLoadEmpty() {
//        super.onLoadEmpty()
//
//        // RecyclerView 被隐藏的话会导致不能 AppBar 不能滑动
//        mListRv.visibility = View.VISIBLE
//        mReuseNoData?.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.background))
//    }
//
//    override fun onLoadError() {
//        super.onLoadError()
//
//        mListRv.visibility = View.VISIBLE
//        mReuseNoConn?.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.background))
//    }
//
//    override fun onLoadDone() {
//        super.onLoadDone()
//
//        filter.visibility = View.VISIBLE
//    }
//
//    companion object {
//
//        const val USER_ID = "user_id"
//        const val COUNT = "count"
//
//        fun getInstance(userId: String, count: PersonalEntity.Count): UserVideoHistoryFragment {
//            return UserVideoHistoryFragment().apply {
//                with(bundleOf(
//                        UserHistoryFragment.USER_ID to userId,
//                        UserHistoryFragment.COUNT to count
//                ))
//            }
//        }
//    }
//
//}