package com.base.datarecovery.activity.recovery

import android.annotation.SuppressLint
import android.graphics.Color
import androidx.activity.addCallback
import com.base.datarecovery.R
import com.base.datarecovery.ads.admob.AdmobInterstitialUtils
import com.base.datarecovery.bean.ConstObject.SCAN_DOCUMENTS
import com.base.datarecovery.bean.ConstObject.SCAN_PHOTOS
import com.base.datarecovery.bean.ConstObject.SCAN_VIDEOS
import com.base.datarecovery.databinding.ActivityFileScanBinding
import com.base.datarecovery.help.BaseActivity
import com.base.datarecovery.utils.BarUtils
import com.base.datarecovery.view.DialogViews.showExitFunctionDialog

/**
 * 文件扫描,遍历文件夹的方式进行
 */
class FileScanActivity : BaseActivity<ActivityFileScanBinding>() {

    private val TAG = "FileScanActivity"
    private var scanOnce: Boolean = false

    private var scanType = 0
    override val binding: ActivityFileScanBinding by lazy {
        ActivityFileScanBinding.inflate(layoutInflater)
    }

    @SuppressLint("SetTextI18n")
    override fun initView() {
        BarUtils.setStatusBarLightMode(this, false)
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)

        scanType = intent.extras?.getInt("Type") ?: 0
        when (scanType) {
            SCAN_PHOTOS -> {
                binding.tvTittle.text = "Photos Recovery"
                binding.ivIcon.setImageResource(R.mipmap.tu_photos_scan)
            }

            SCAN_DOCUMENTS -> {
                binding.tvTittle.text = "Documents Recovery"
                binding.ivIcon.setImageResource(R.mipmap.tu_documents_scan)
            }

            SCAN_VIDEOS -> {
                binding.tvTittle.text = "Videos Recovery"
                binding.ivIcon.setImageResource(R.mipmap.tu_videos_scan)
            }
        }
    }

    override fun initListener() {
        onBackPressedDispatcher.addCallback {
            showExitFunctionDialog {
                if (it) {
                    AdmobInterstitialUtils.showInterstitialAd(this@FileScanActivity) {
                        finishToMain()
                    }
                } else {
                    finishToMain()
                }
            }
        }
        binding.flFanhui.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
    }


    private fun requestPermission() {

    }

}