package com.zxhy.fastfilemanagerpro

import android.app.Activity
import android.app.Application
import android.app.LauncherActivity
import android.content.Context
import android.os.Bundle
import android.util.Log
import com.zxhy.fastfilemanagerpro.kokoads.KokoOpenAdManager

@Suppress("NAME_SHADOWING")
class MyApplication : Application(), Application.ActivityLifecycleCallbacks {

    private val TAG = "MyApplication"

    //开屏广告
    lateinit var kokoOpenAdManager: KokoOpenAdManager

    private var currentActivity: Activity? = null

    override fun onCreate() {
        super.onCreate()
        ApplicationContext = this
        registerActivityLifecycleCallbacks(this)
        initAdManager()
    }

    companion object {
        lateinit var ApplicationContext: Context
    }


    //region admob广告
    fun initAdManager() {
        kokoOpenAdManager = KokoOpenAdManager()
    }

    fun loadAd(activity: Activity) {
        kokoOpenAdManager.loadAd(activity)
    }
    //endregion

    //region Activity生命周期回调
    override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) = Unit
    override fun onActivityStarted(activity: Activity) {
//        currentActivity = activity
//        Log.e(TAG, "$currentActivity")
//        currentActivity?.let { activity ->
//            if (activity::class.java.name == KokoLaunchActivity::class.java.name) {
//                kokoOpenAdManager.showAdIfAvailable(activity)
//            }
//        }
    }

    override fun onActivityResumed(activity: Activity) = Unit
    override fun onActivityPaused(activity: Activity) = Unit
    override fun onActivityStopped(activity: Activity) = Unit
    override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) = Unit
    override fun onActivityDestroyed(activity: Activity) = Unit
    //endregion
}