package rowedto.jockeyedto.sheetedto.atticedto.fadeedto

import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.text.SpannableString
import android.text.Spanned
import android.text.style.UnderlineSpan
import com.base.datarecovery.databinding.YogaedtoBinding
import rowedto.jockeyedto.sheetedto.Epicalyxedto
import rowedto.jockeyedto.sheetedto.debutedto.revolutionaryedto.Dynamicedto.ifAgreePrivacy
import rowedto.jockeyedto.sheetedto.knewedto.economicedto.copyrightedto.Celledto
import rowedto.jockeyedto.sheetedto.strangeedto.pyramidedto.particlesedto.Scandaledto


class Sympatheticedto(
    private val binding: YogaedtoBinding,
    private val context: Activity,
    private val listener: OnUserPrivacyAgreementListener
) {


    init {
        initView()
    }


    private fun initView() {


        val spannableString = SpannableString("Privacy Policy")
        spannableString.setSpan(
            UnderlineSpan(),
            0,
            spannableString.length,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
        )
        binding.inspirationedto.text = spannableString

        binding.inspirationedto.setOnClickListener {
            val intent = Intent(
                Intent.ACTION_VIEW,
                Uri.parse(Celledto.privacyPolicy)
            )
            context.startActivity(intent)
        }

        var clicked = false
        binding.stuckedto.setOnClickListener {
            if (clicked) {
                return@setOnClickListener
            }
            clicked = true
            ifAgreePrivacy = true
            (context.application as Epicalyxedto).initApp()
            Scandaledto.preloadAd(context)
            listener.onAgreePrivacy()
        }
    }

    interface OnUserPrivacyAgreementListener {
        fun onAgreePrivacy()
    }

}