package com.gh.gamecenter.video.videomanager

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.common.utils.dip2px
import com.gh.gamecenter.common.view.FixLinearLayoutManager
import com.gh.gamecenter.common.view.GridSpacingItemDecoration
import com.gh.gamecenter.common.baselist.ListFragment
import com.gh.gamecenter.entity.VideoEntity
import com.gh.gamecenter.video.upload.view.UploadVideoActivity

class VideoVerifyFragment : ListFragment<VideoEntity, VideoVerifyViewModel>() {

    private var mVerifyAdapter: VideoVerifyAdapter? = null

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == UploadVideoActivity.RESULT_CODE_VIDEO) {
            onLoadRefresh()
        }
    }

    override fun getItemDecoration(): RecyclerView.ItemDecoration? {
        return GridSpacingItemDecoration(1, 0, false, 8F.dip2px())
    }

    override fun provideListAdapter(): VideoVerifyAdapter {
        if (mVerifyAdapter == null) {
            mVerifyAdapter = VideoVerifyAdapter(requireContext(), mListViewModel, mEntrance)
        }
        return mVerifyAdapter!!
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mListRv.layoutManager = FixLinearLayoutManager(requireContext())
    }
}