package com.xm.test.myfilemaster.activity

import android.os.Bundle
import android.widget.ListView
import com.kongzue.dialogx.dialogs.WaitDialog
import com.xm.test.myfilemaster.R
import com.xm.test.myfilemaster.base.BaseActivity
import com.xm.test.myfilemaster.model.FileBean
import com.xm.test.myfilemaster.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)
        }
    }

}