package rowedto.jockeyedto.sheetedto.atticedto

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.PrisonedtoBinding
import rowedto.jockeyedto.sheetedto.atticedto.calfedto.despiseedto.matrixedto.Upsetedto
import rowedto.jockeyedto.sheetedto.atticedto.directionedto.noxiousedto.batedto.Celebrationedto
import rowedto.jockeyedto.sheetedto.atticedto.harboredto.Poemedto
import rowedto.jockeyedto.sheetedto.atticedto.harboredto.Reignedto
import rowedto.jockeyedto.sheetedto.atticedto.jobedto.basinedto.civilianedto.Searchedto
import rowedto.jockeyedto.sheetedto.atticedto.openedto.postedto.Killeredto
import rowedto.jockeyedto.sheetedto.atticedto.peakedto.affinityedto.jacketedto.Scrapedto
import rowedto.jockeyedto.sheetedto.atticedto.rededto.knifeedto.economyedto.Viableedto
import rowedto.jockeyedto.sheetedto.atticedto.salonedto.safetyedto.makeupedto.Massedto
import rowedto.jockeyedto.sheetedto.atticedto.strainedto.wolfedto.furtheredto.Archiveedto
import rowedto.jockeyedto.sheetedto.atticedto.teacheredto.characteristicedto.Surroundedto
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.APP_MANAGER
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.APP_PROCESS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.BATTERY_INFO
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.JUNK_CLEANER
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.LARGE_FILE
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.PRIVACY_SPACE
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.RECOVERY_AUDIOS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.RECOVERY_DOCUMENTS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.RECOVERY_PHOTOS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.RECOVERY_VIDEOS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.REPEAT_PHOTOS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.SCAN_AUDIOS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.SCAN_DOCUMENTS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.SCAN_PHOTOS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.SCAN_VIDEOS
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.SCREENSHOT_CLEANER
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.WHATSAPP_CLEANER
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.privacyPinPassword
import rowedto.jockeyedto.sheetedto.knewedto.economicedto.copyrightedto.Crossingedto
import rowedto.jockeyedto.sheetedto.knewedto.economicedto.copyrightedto.Suitcaseedto.toFormatSize
import rowedto.jockeyedto.sheetedto.meadowedto.naturaledto.idealedto.Calledto
import rowedto.jockeyedto.sheetedto.raceedto.pavementedto.Dishedto
import rowedto.jockeyedto.sheetedto.raceedto.pavementedto.Spareedto
import rowedto.jockeyedto.sheetedto.raceedto.pavementedto.Stewardedto
import rowedto.jockeyedto.sheetedto.strangeedto.pyramidedto.particlesedto.Scandaledto

class Softedto : Crossingedto<PrisonedtoBinding>() {
    private val TAG = "ResultActivity"

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

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

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

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

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

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

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

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

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

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

                        })
                    }
                }

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

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

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

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

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

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

        val from = intent.extras?.getString("from")
        Dishedto.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.giantedto.text = "Cleaned up $size"
                } else {
                    binding.giantedto.text = "No junk files found."
                }
                Stewardedto.getInstance()
                    .put("last_use_junk_cleaner", System.currentTimeMillis())
            }

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


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

                }
            }
        })
        binding.defeatedto.setOnClickListener {
            onBackPressedDispatcher.onBackPressed()
        }
        Scandaledto.admobMaxShowNativeAd(this@Softedto, binding.breatheedto)
    }

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