package com.simplecleaner.app.ui.guide

import android.view.View
import androidx.activity.addCallback
import com.simplecleaner.app.R
import com.simplecleaner.app.base.BaseActivity
import com.simplecleaner.app.business.ads.AdsMgr
import com.simplecleaner.app.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
            }
        }
    }
}