package com.gh.common.provider

import android.content.Context
import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.R
import com.gh.gamecenter.core.provider.IAppProvider
import com.gh.gamecenter.core.provider.IFlavorProvider
import com.gh.gamecenter.va.VCore
import com.halo.assistant.HaloApp

@com.therouter.inject.ServiceProvider
class AppProviderImpl : IAppProvider {

    override fun getAppName(): String {
        return HaloApp.getInstance().getString(R.string.app_name)
    }

    override fun getAppVersion(): String {
        return BuildConfig.VERSION_NAME
    }

    override fun getGid(): String {
        return HaloApp.getInstance().gid ?: ""
    }

    override fun refreshGid() {
        HaloApp.getInstance().refreshGid()
    }

    override fun getOaid(): String {
        return HaloApp.getInstance().oaid ?: ""
    }

    override fun getChannel(): String {
        return HaloApp.getInstance().channel ?: ""
    }

    override fun setChannel(channel: String) {
        HaloApp.getInstance().channel = channel
    }

    override fun getUserAgent(): String {
        return HaloApp.getInstance().userAgent ?: ""
    }

    override fun getServerUserMark(): String {
        return HaloApp.getInstance().serverUserMark ?: ""
    }

    override fun getDeviceRamSize(): Long {
        return HaloApp.getInstance().deviceRamSize
    }

    override fun getTemporaryLocalDeviceId(): String {
        return HaloApp.getInstance().temporaryLocalDeviceId ?: ""
    }

    override fun isUserAcceptPrivacyPolicy(context: Context): Boolean {
        return HaloApp.isUserAcceptPrivacyPolicy(context)
    }

    override fun put(key: String, any: Any) {
        HaloApp.put(key, any)
    }

    override fun get(key: String, isRemove: Boolean): Any? {
        return HaloApp.get(key, isRemove)
    }

    override fun getFlavorProvider(): IFlavorProvider {
        return HaloApp.getInstance().flavorProvider
    }

    override fun getFlavor(): String {
        return BuildConfig.FLAVOR
    }

    override fun getIsBrandNewInstall(): Boolean {
        return HaloApp.getInstance().isBrandNewInstall
    }

    override fun setDisableSplashAdTemporarily(isDisable: Boolean) {
        HaloApp.getInstance().isDisableSplashAdTemporarily = isDisable
    }

    override fun getPluginVersion(): String = VCore.getInstance().getPluginVersion()

    override fun initImageLoaderIfNeeded() {
        HaloApp.getInstance().initFresco()
    }

}