package com.base.filerecoveryrecyclebin.activity.recovery

import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Environment
import androidx.activity.addCallback
import com.base.filerecoveryrecyclebin.R
import com.base.filerecoveryrecyclebin.ads.AdmobMaxHelper
import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_AUDIOS
import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_DOCUMENTS
import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_PHOTOS
import com.base.filerecoveryrecyclebin.bean.ConstObject.SCAN_VIDEOS
import com.base.filerecoveryrecyclebin.bean.FolderBean
import com.base.filerecoveryrecyclebin.databinding.ActivityFileRecoveredBinding
import com.base.filerecoveryrecyclebin.help.BaseActivity
import com.base.filerecoveryrecyclebin.utils.BarUtils
import java.io.File

class FileRecoveredActivity : BaseActivity<ActivityFileRecoveredBinding>() {

    override val binding: ActivityFileRecoveredBinding by lazy {
        ActivityFileRecoveredBinding.inflate(layoutInflater)
    }


    @SuppressLint("SetTextI18n")
    override fun initView() {

        BarUtils.setStatusBarLightMode(this, true)
        BarUtils.setStatusBarColor(this, Color.TRANSPARENT)

        val number = intent.extras?.getInt("Number") ?: 0
        val scanType = intent.extras?.getInt("ScanType")

        binding.tvNumber.text = number.toString()
        val type = when (scanType) {
            SCAN_PHOTOS -> if (number == 1) "Photo" else "Photos"
            SCAN_VIDEOS -> if (number == 1) "Video" else "Videos"
            SCAN_DOCUMENTS -> if (number == 1) "Document" else "Documents"
            SCAN_AUDIOS -> if (number == 1) "Audio" else "Audios"
            else -> ""
        }
        binding.tvType.text = type

        val appName = this.resources.getString(R.string.app_name).replace("/", " ")
        val appDir = File(Environment.getExternalStorageDirectory(), appName)
        binding.tvDir.text = "Recovered in $appDir"
    }

    override fun initListener() {

        binding.flFanhui.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
        onBackPressedDispatcher.addCallback {
            AdmobMaxHelper.admobMaxShowInterstitialAd(this@FileRecoveredActivity) {
                finishToMain()
            }
        }
        binding.tvContinue.setOnClickListener {
            AdmobMaxHelper.admobMaxShowInterstitialAd(this) {
                finish()
            }
        }
        binding.tvFinish.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
    }


}