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 ScanLargeFilesActivity : BaseActivity() {

    private lateinit var mFilesItemListView: ListView
    private var mFileItemList = ArrayList<FileBean>()

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

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setTitle("Scan Large Files")
        isNewShow(false)
        isCurrantTvShow(false)

        mInitView()
    }

    fun mInitView(){
        mFilesItemListView = findViewById<ListView>(R.id.files_item_listview)

        WaitDialog.show("Please Wait!")
        Thread(Runnable {
            mFileItemList = FileUtil.search10MFiles(this, 10 * 1024 * 1024)
            runOnUiThread {
                setAdapter(mFilesItemListView, mFileItemList)
                WaitDialog.dismiss()
            }
        }).start()
        setOnClickBtn()
    }

    override fun onBackPressed() {
        WaitDialog.dismiss()
        super.onBackPressed()
        isNewShow(false)
    }
}