package com.zxhyis.toolss.ui.start

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.zxhyis.toolss.R
import com.zxhyis.toolss.ad.AdmobUtils
import com.zxhyis.toolss.databinding.FragmentStartPageBinding


class StartPageFragment(val drawable: Int) : Fragment() {

    private lateinit var binding: FragmentStartPageBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val root = inflater.inflate(R.layout.fragment_start_page, container, false)
        binding = FragmentStartPageBinding.bind(root)
        return root
    }

    @SuppressLint("SetTextI18n")
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding.fl.background = ContextCompat.getDrawable(requireContext(), drawable)
        showAd()
    }

    fun showAd() {
        when (drawable) {
            R.drawable.start_banner1 -> {
               // MaxAdUtils.showMaxNativeAd(null, binding.flAd)
                AdmobUtils.showNativeAd(requireActivity(),binding.flAd)
            }

            R.drawable.start_banner2 -> {
                //MaxAdUtils.showMaxNativeAd(null, binding.flAd)
                AdmobUtils.showNativeAd(requireActivity(),binding.flAd)
            }

            R.drawable.start_banner3 -> {
               // MaxAdUtils.showMaxNativeAd(null, binding.flAd)
                AdmobUtils.showNativeAd(requireActivity(),binding.flAd)
            }

            R.drawable.start_banner4 -> {
               // MaxAdUtils.showMaxNativeAd(null, binding.flAd)
                AdmobUtils.showNativeAd(requireActivity(),binding.flAd)
            }
        }
    }

}