package com.test.mydemo3.activity

import android.os.Bundle
import android.util.Log
import android.util.SparseBooleanArray
import android.view.View
import android.widget.ListView
import com.kongzue.dialogx.dialogs.WaitDialog
import com.test.mydemo3.R
import com.test.mydemo3.adapter.FilesItemViewAdapter
import com.test.mydemo3.base.BaseActivity
import com.test.mydemo3.model.FileBean
import com.test.mydemo3.model.FilesItemBean
import com.test.mydemo3.util.FileUtil

class ScanEmptyFilesActivity : BaseActivity() {

    private lateinit var mFilesItemListView: ListView
    companion object{
        private var mFileItemList = ArrayList<FileBean>()
    }


    override fun getLayout(): Int {
        return R.layout.activity_scan_empt_layout
    }



    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        super.setTitle("Scan Empty Files")

        mInitView()
    }

    fun mInitView(){
        mFilesItemListView = findViewById<ListView>(R.id.files_item_listview)
        isCurrantTvShow(false)
        isNewShow(false)
        setOnClickBtn()
        getFileDatas()

    }

    private fun getFileDatas() {
        if (mFileItemList.size == 0) {
            WaitDialog.show("Please Wait..")
            Thread(Runnable {
                FileUtil.scanEmptyFiles(FileUtil.EXTERNAL_STORAGE, mFileItemList)
                runOnUiThread {
                    setAdapter(mFilesItemListView, mFileItemList)
                    WaitDialog.dismiss()
                }
            }).start()
        } else {
            setAdapter(mFilesItemListView, mFileItemList)
        }
    }

}