package com.zxhyis.toolss.ui.page.recyclebin

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.zxhyis.toolss.base.TopFragment
import com.zxhyis.toolss.databinding.FragmentPictureBinding
import com.zxhyis.toolss.logic.ImageInfoBean
import com.zxhyis.toolss.logic.Logic
import com.zxhyis.toolss.ui.adapter.ImageAdapter
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch


class PictureFragment : TopFragment<FragmentPictureBinding>() {

    private var dataList = ArrayList<ImageInfoBean>()
    private lateinit var imageAdapter: ImageAdapter

    override fun createBinding(
        inflater: LayoutInflater,
        container: ViewGroup?
    ): FragmentPictureBinding {
        return FragmentPictureBinding.inflate(inflater, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        init()
        initRv()
    }

    private fun init() {
        if (checkData()) {
            haveDataUI()
        } else {
            haveNoDataUI()
        }

    }

    private fun initRv() {
        CoroutineScope(Dispatchers.IO).launch {


            imageAdapter= ImageAdapter(dataList,requireActivity(),object :Logic{
                override fun doLogic() {

                }
            })

            launch(Dispatchers.Main) {


            }

        }

    }

    fun changeImageUi(){
        imageAdapter.setShow()
    }

    private fun haveDataUI() {
        mK.apply {
            rv1.visibility = View.VISIBLE
            icNoFile.visibility = View.GONE
            tvNoFile.visibility = View.GONE
        }
    }

    private fun haveNoDataUI() {
        mK.apply {
            rv1.visibility = View.GONE
            icNoFile.visibility = View.VISIBLE
            tvNoFile.visibility = View.VISIBLE
        }
    }


    private fun checkData(): Boolean {
        return true
    }


    fun deleteImages(){

    }

    fun recoveryImages(){

    }

}