package com.rgt.superr.ui.guide

import android.view.View
import androidx.activity.addCallback
import com.rgt.superr.R
import com.rgt.superr.base.BaseActivity
import com.rgt.superr.business.ads.AdsMgr
import com.rgt.superr.databinding.ActivityGuideCleanBinding

class GuideCleanActivity : BaseActivity<ActivityGuideCleanBinding>(ActivityGuideCleanBinding::inflate) {

    override fun initView() {
        super.initView()
        val flag = changeLanguage(this)
        if (!flag) {
            changeNative()
        }
    }

    override fun initListener() {
        super.initListener()
        binding.llPhoto.setOnClickListener {
            binding.iv1.isSelected = !binding.iv1.isSelected
            changeNative()
        }
        binding.llVideo.setOnClickListener {
            binding.iv2.isSelected = !binding.iv2.isSelected
            changeNative()
        }

        binding.llAudio.setOnClickListener {
            binding.iv3.isSelected = !binding.iv3.isSelected
            changeNative()
        }

        binding.llDocument.setOnClickListener {
            binding.iv4.isSelected = !binding.iv4.isSelected
            changeNative()
        }

        onBackPressedDispatcher.addCallback {
            finishToMain()
        }

        binding.flContinue.setOnClickListener {
            goToAc(GuideActivity::class.java)
            finish()
        }
    }

    private fun changeNative() {
        AdsMgr.showNative(binding.flAd, R.layout.layout_admob_native_custom) {
            if (it == null) {
                binding.flAd.removeAllViews()
                binding.flAd.visibility = View.VISIBLE
            }
        }
    }
}