package rallyedto.finishedto.fictionedto.thanedto

import android.annotation.SuppressLint
import android.content.Intent
import android.view.View
import androidx.core.view.isVisible
import com.base.datarecovery.R
import com.base.datarecovery.databinding.DistortedtoBinding
import rallyedto.battleedto.acresedto.Dolledto
import rallyedto.finishedto.Acceptedto
import rallyedto.policeedto.huntedto.Snuggleedto
import rallyedto.sunedto.tumouredto.majorityedto.loseedto.Togetheredto


class Heroinedto : Dolledto<DistortedtoBinding>() {

    var page: Int = 0

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

    @SuppressLint("SetTextI18n")
    override fun setView() {
        if (page == 0) {
            binding.jeweledto.visibility = View.VISIBLE
            Togetheredto.showNativeAd(
                requireActivity(),
                binding.jeweledto
            )
        } else {
            binding.jeweledto.visibility = View.INVISIBLE
        }
        binding.root.postDelayed({
            binding.lighteredto.isVisible = true
        }, 2000)
        when (page) {
            0 -> {
                binding.ditchedto.setImageResource(R.mipmap.displaceedto)
                binding.dineedto.setImageResource(R.mipmap.forthedto)
                binding.completelyedto.setImageResource(R.mipmap.forthedto)
                binding.cutedto.setImageResource(R.mipmap.forthedto)
                binding.usefuledto.setImageResource(R.mipmap.regretedto)
                binding.libertarianedto.text = "Bring Your Memories Back"
                binding.tributeedto.text = "Recover Deleted Photos and Videos"
            }

            1 -> {
                binding.usefuledto.setImageResource(R.mipmap.removeedto)
                binding.libertarianedto.text = "Fast Recovery, No Stress"
                binding.tributeedto.text = "Quickly scan and restore your files with afew taps"
                binding.ditchedto.setImageResource(R.mipmap.forthedto)
                binding.dineedto.setImageResource(R.mipmap.displaceedto)
                binding.completelyedto.setImageResource(R.mipmap.forthedto)
                binding.cutedto.setImageResource(R.mipmap.forthedto)
            }

            2 -> {
                binding.usefuledto.setImageResource(R.mipmap.titleedto)
                binding.libertarianedto.text = "Everything You Need,Recovered"
                binding.tributeedto.text =
                    "Search, preview, and recover various other files-all in one place"
                binding.ditchedto.setImageResource(R.mipmap.forthedto)
                binding.dineedto.setImageResource(R.mipmap.forthedto)
                binding.completelyedto.setImageResource(R.mipmap.displaceedto)
                binding.cutedto.setImageResource(R.mipmap.forthedto)
            }

            3 -> {
                binding.usefuledto.setImageResource(R.mipmap.titleedto)
                binding.libertarianedto.text = "Everything You Need,Recovered"
                binding.tributeedto.text =
                    "Search, preview, and recover various other files-all in one place"
                binding.ditchedto.setImageResource(R.mipmap.forthedto)
                binding.dineedto.setImageResource(R.mipmap.forthedto)
                binding.completelyedto.setImageResource(R.mipmap.displaceedto)
                binding.cutedto.setImageResource(R.mipmap.forthedto)
            }

            4 -> {
                binding.usefuledto.setImageResource(R.mipmap.rockedto)
                binding.libertarianedto.text = "All-in-One Solution"
                binding.tributeedto.text = "Recover, manage, and organize your files—all in one intuitive interface."
                binding.ditchedto.setImageResource(R.mipmap.forthedto)
                binding.dineedto.setImageResource(R.mipmap.forthedto)
                binding.completelyedto.setImageResource(R.mipmap.forthedto)
                binding.cutedto.setImageResource(R.mipmap.displaceedto)
            }
        }
        binding.slantedto.setOnClickListener {
            if (page == 0) {
                (requireActivity() as Farmedto).setPosition(1)
            } else if (page == 1) {
                (requireActivity() as Farmedto).setPosition(2)
            } else if (page == 2) {
                (requireActivity() as Farmedto).setPosition(3)
            } else if (page == 3) {
                (requireActivity() as Farmedto).setPosition(4)
            } else {
                jumpNext()
            }
        }
        binding.lighteredto.setOnClickListener {
            jumpNext()
        }

    }

    private fun jumpNext() {
        Snuggleedto.isGuide = true
        (requireActivity() as Farmedto).admobMaxShowInterstitialAd {
            startActivity(Intent(requireContext(), Acceptedto::class.java))
        }
//        val showAd = SPUtils.getInstance().getString("isShowGuideAd", "0")?.toInt()
//        if (showAd == 1) {
//
//        } else {
//            if (!Wageedto.ifGuest) {
//                startActivity(Intent(requireContext(), DeviceScanActivity::class.java))
//                requireActivity().finish()
//            }else{
//                startActivity(Intent(requireContext(), Acceptedto::class.java))
//            }
//        }
    }
}