package com.base.filerecoveryrecyclebin.activity.splash

import android.app.Activity
import android.content.Intent
import android.util.Log
import com.base.filerecoveryrecyclebin.activity.MainActivity
import com.base.filerecoveryrecyclebin.activity.XzLoadingActivity
import com.base.filerecoveryrecyclebin.activity.battery.BatteryInfoAnimationActivity
import com.base.filerecoveryrecyclebin.activity.guide.WhichWantGuideActivity
import com.base.filerecoveryrecyclebin.activity.junkclean.ScanJunkActivity
import com.base.filerecoveryrecyclebin.activity.photomanager.PhotoManagerAnimationActivity
import com.base.filerecoveryrecyclebin.activity.recovery.FileScanResultActivity
import com.base.filerecoveryrecyclebin.bean.ConstObject
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_BATTERY_INFO
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_JUNK_CLEAN_PUSH
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_RECOVERY_DOCUMENTS
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_RECOVERY_PHOTOS
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_RECOVERY_VIDEOS
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_SCREENSHOT_CLEAN
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_SIMILAR_IMAGE
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_WHEATHER
import com.base.filerecoveryrecyclebin.bean.ConstObject.ID_XINGZUO
import com.base.filerecoveryrecyclebin.bean.ConstObject.isGuide
import com.base.filerecoveryrecyclebin.view.WeatherInterface

object StartUtils {

    private val TAG = "SplashJumpUtils"
    fun jumpNextPage(context: Activity) {

        var jumpType = context.intent.getIntExtra("actionId", 0)

        Log.e(TAG, "actionId: $jumpType")

        if (jumpType == 0) {
            val uri = context.intent.data
            val str = (uri?.getQueryParameter("type") ?: "0")
            jumpType = str.toIntOrNull() ?: 0
            if (jumpType != 0) {
            }
        }
        when (jumpType) {
//=================================主动广播=======================================
            ID_JUNK_CLEAN_PUSH -> {
                context.startActivity(Intent(context, ScanJunkActivity::class.java))
            }
            ID_SIMILAR_IMAGE -> {
                context.startActivity(Intent(context, PhotoManagerAnimationActivity::class.java))
            }
            ID_SCREENSHOT_CLEAN -> {
                context.startActivity(Intent(context, PhotoManagerAnimationActivity::class.java))
            }
            ID_RECOVERY_PHOTOS -> {
                context.startActivity(Intent(context, FileScanResultActivity::class.java).putExtra("ScanType",ConstObject.SCAN_PHOTOS))
            }
            ID_RECOVERY_VIDEOS -> {
                context.startActivity(Intent(context, FileScanResultActivity::class.java).putExtra("ScanType",ConstObject.SCAN_VIDEOS))
            }
            ID_RECOVERY_DOCUMENTS -> {
                context.startActivity(Intent(context, FileScanResultActivity::class.java).putExtra("ScanType",ConstObject.SCAN_DOCUMENTS))
            }
            ID_BATTERY_INFO -> {
                context.startActivity(Intent(context, BatteryInfoAnimationActivity::class.java))
            }
            ID_XINGZUO->{
                context.startActivity(Intent(context, XzLoadingActivity::class.java))
            }
            ID_WHEATHER->{
                context.startActivity(Intent(context, WeatherInterface::class.java))
            }


//================================被动广播=========================================

            else -> {
                val isHotLaunch = context.intent?.extras?.getBoolean("isHotLaunch", false) ?: false
                if (!isHotLaunch) {
                    if (!isGuide) {
//                        context.startActivity(Intent(context, GuideActivity::class.java))
                        context.startActivity(Intent(context, WhichWantGuideActivity::class.java))
                        isGuide = true
                    } else {
                        context.startActivity(Intent(context, MainActivity::class.java))
                    }

                }
            }
        }
        context.finish()
    }
}