package importantedto.appliededto.surgeonedto.promiseedto

import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import androidx.activity.OnBackPressedCallback
import androidx.core.view.updatePadding
import com.base.datarecovery.databinding.AsideedtoBinding
import importantedto.admireedto.sweptedto.Differenceedto
import importantedto.afteredto.constitutionaledto.Constraintedto.toFormatSize
import importantedto.afteredto.constitutionaledto.Murderedto
import importantedto.appliededto.surgeonedto.promiseedto.enteredto.eatenedto.ridingedto.Madeedto
import importantedto.appliededto.surgeonedto.promiseedto.freedomedto.Spilledto
import importantedto.appliededto.surgeonedto.promiseedto.nobleedto.defendedto.tastyedto.Weakedto
import importantedto.appliededto.surgeonedto.promiseedto.obtainedto.museumedto.outletedto.Probablyedto
import importantedto.appliededto.surgeonedto.promiseedto.petedto.Delayedto
import importantedto.appliededto.surgeonedto.promiseedto.prospectedto.consumptionedto.blameedto.Reserveedto
import importantedto.appliededto.surgeonedto.promiseedto.rapeedto.Eyebrowedto
import importantedto.appliededto.surgeonedto.promiseedto.respectableedto.prisonedto.comfortableedto.Exclaimededto
import importantedto.appliededto.surgeonedto.promiseedto.respectableedto.prisonedto.comfortableedto.Knitedto
import importantedto.appliededto.surgeonedto.promiseedto.steeledto.Liveredto
import importantedto.appliededto.surgeonedto.promiseedto.wonderedto.Tiptoeedto
import importantedto.concreteedto.cameedto.Hateedto.APP_MANAGER
import importantedto.concreteedto.cameedto.Hateedto.APP_PROCESS
import importantedto.concreteedto.cameedto.Hateedto.BATTERY_INFO
import importantedto.concreteedto.cameedto.Hateedto.JUNK_CLEANER
import importantedto.concreteedto.cameedto.Hateedto.LARGE_FILE
import importantedto.concreteedto.cameedto.Hateedto.PRIVACY_SPACE
import importantedto.concreteedto.cameedto.Hateedto.RECOVERY_AUDIOS
import importantedto.concreteedto.cameedto.Hateedto.RECOVERY_DOCUMENTS
import importantedto.concreteedto.cameedto.Hateedto.RECOVERY_PHOTOS
import importantedto.concreteedto.cameedto.Hateedto.RECOVERY_VIDEOS
import importantedto.concreteedto.cameedto.Hateedto.REPEAT_PHOTOS
import importantedto.concreteedto.cameedto.Hateedto.SCAN_AUDIOS
import importantedto.concreteedto.cameedto.Hateedto.SCAN_DOCUMENTS
import importantedto.concreteedto.cameedto.Hateedto.SCAN_PHOTOS
import importantedto.concreteedto.cameedto.Hateedto.SCAN_VIDEOS
import importantedto.concreteedto.cameedto.Hateedto.SCREENSHOT_CLEANER
import importantedto.concreteedto.cameedto.Hateedto.WHATSAPP_CLEANER
import importantedto.concreteedto.cameedto.Hateedto.privacyPinPassword
import importantedto.deserveedto.manufactureredto.viableedto.Policeedto
import importantedto.gallonedto.Transcendedto
import importantedto.gallonedto.Tumbleedto
import importantedto.gallonedto.Waitedto

class Halcyonedto : Murderedto<AsideedtoBinding>() {
    private val TAG = "ResultActivity"

    override val binding: AsideedtoBinding by lazy {
        AsideedtoBinding.inflate(layoutInflater)
    }
    private lateinit var adapter: Policeedto

    @SuppressLint("SetTextI18n", "NotifyDataSetChanged")
    override fun initView() {
        Transcendedto.setStatusBarColor(this, Color.TRANSPARENT)
        binding.resourceedto.updatePadding(top = Transcendedto.getStatusBarHeight())
        adapter = Policeedto {
            when (it) {

                JUNK_CLEANER -> {
                    startActivity(Intent(this, Reserveedto::class.java))
                }

                REPEAT_PHOTOS -> {
                    startActivity(Intent(this, Weakedto::class.java))
                }

                SCREENSHOT_CLEANER -> {
                    startActivity(Intent(this, Eyebrowedto::class.java))
                }

                RECOVERY_PHOTOS -> {
                    startActivity(Intent(this, Spilledto::class.java).apply {
                        putExtra("ScanType", SCAN_PHOTOS)
                    })
                }

                RECOVERY_VIDEOS -> {
                    startActivity(Intent(this, Spilledto::class.java).apply {
                        putExtra("ScanType", SCAN_VIDEOS)
                    })
                }

                RECOVERY_DOCUMENTS -> {
                    startActivity(Intent(this, Spilledto::class.java).apply {
                        putExtra("ScanType", SCAN_DOCUMENTS)
                    })
                }

                RECOVERY_AUDIOS -> {
                    startActivity(Intent(this, Spilledto::class.java).apply {
                        putExtra("ScanType", SCAN_AUDIOS)
                    })
                }

                PRIVACY_SPACE -> {
                    if (privacyPinPassword.isNotEmpty()) {
                        startActivity(Intent(this, Knitedto::class.java))
                    } else {
                        startActivity(Intent(this, Exclaimededto::class.java).apply {

                        })
                    }
                }

                WHATSAPP_CLEANER -> {
                    startActivity(Intent(this, Tiptoeedto::class.java))
                }

                LARGE_FILE -> {
                    startActivity(Intent(this, Madeedto::class.java))
                }

                APP_PROCESS -> {
                    startActivity(Intent(this, Delayedto::class.java))
                }

                APP_MANAGER -> {
                    startActivity(Intent(this, Liveredto::class.java))
                }

                BATTERY_INFO -> {
                    startActivity(Intent(this, Probablyedto::class.java))
                }

            }
            finish()
        }
        binding.deeredto.adapter = adapter
        adapter.updateListPosition()
        adapter.notifyDataSetChanged()

        val from = intent.extras?.getString("from")
        Tumbleedto.logDebug(TAG, "from=$from")
        when (from) {
            JUNK_CLEANER -> {
                if (intent.getLongExtra("clean_size", 0L) > 0) {
                    val size = intent.getLongExtra("clean_size", 0L).toFormatSize(1)
                    binding.nameedto.text = "Cleaned up $size"
                } else {
                    binding.nameedto.text = "No junk files found."
                }
                Waitedto.getInstance()
                    .put("last_use_junk_cleaner", System.currentTimeMillis())
            }

            else -> {
                binding.nameedto.text = "Completed!"
            }
        }
        from?.let {
            binding.assaultedto.text = it
            adapter.removeItem(it)
        }


        onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
            override fun handleOnBackPressed() {
                val s = Waitedto.getInstance().getString("isShowBackIntAd", "0").toIntOrNull()
                    ?: 0
                if (s == 1) {
                    Differenceedto.admobMaxShowInterstitialAd(this@Halcyonedto,false) {
                        finishToMain()
                    }
                } else {
                    finishToMain()

                }
            }
        })
        binding.amedto.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
        Differenceedto.admobMaxShowNativeAd(this@Halcyonedto, binding.agileedto)
    }

    override fun onDestroy() {
        super.onDestroy()
        binding.lastedto.clearAnimation()
    }
}