package com.swiftcleaner.chovey.view.activity

import android.content.Intent
import android.widget.CheckBox
import android.widget.LinearLayout
import com.swiftcleaner.chovey.R
import com.swiftcleaner.chovey.business.newAdmob.AdmobHelps
import com.swiftcleaner.chovey.databinding.ActivityWhichWantGuideBinding
import com.swiftcleaner.chovey.view.BaseActivity

class WhichWantGuideActivity : BaseActivity<ActivityWhichWantGuideBinding>() {

    private val checkListGoogle = mutableListOf<CheckBox>()
    private val checkLinGO = mutableListOf<LinearLayout>()
    private var isRefreshAd = false
    override fun getViewBinding(): ActivityWhichWantGuideBinding {
        return ActivityWhichWantGuideBinding.inflate(layoutInflater)
    }

    override fun initView() {
        checkLinGO.add(binding.ll1)
        checkLinGO.add(binding.ll2)
        checkLinGO.add(binding.ll3)
        checkLinGO.add(binding.ll4)
        checkListGoogle.add(binding.checkbox1)
        checkListGoogle.add(binding.checkbox2)
        checkListGoogle.add(binding.checkbox3)
        checkListGoogle.add(binding.checkbox4)
        checkLinGO.forEachIndexed { index, linearLayout ->
            linearLayout.setOnClickListener {
                if (!it.isSelected) getAppAd()
                it.isSelected = !it.isSelected
                checkListGoogle[index].isChecked = !checkListGoogle[index].isChecked
                isRefreshAd = true
            }
        }
        getAppAd()
        binding.tvNext.setOnClickListener {
            startActivity(Intent(this, GuideActivity::class.java))
            finish()
        }
    }

    override fun initData() {

    }

    private fun getAppAd() {
        if (!isRefreshAd) AdmobHelps.showNativeAd(this, binding.flAd, layout = R.layout.layout_ad_native_guide)

    }

}