package com.gh.gamecenter.provider

import android.app.Application
import android.text.TextUtils
import com.gh.gamecenter.common.constant.Config
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.utils.PackageFlavorHelper
import com.gh.gamecenter.core.utils.SPUtils
import com.leon.channel.helper.ChannelReaderUtil

class ChannelProviderImp : ChannelProvider {
    override fun getChannelStr(application: Application): String {
        var channel = ChannelReaderUtil.getChannel(application)
        if (channel == null || TextUtils.isEmpty(channel.trim())) {
            channel = if (PackageFlavorHelper.IS_TEST_FLAVOR) {
                Config.DEFAULT_CHANNEL
            } else {
                Config.DEFAULT_CHANNEL_FOR_RELEASE
            }
        }
        if (PackageFlavorHelper.IS_TEST_FLAVOR) {
            channel = SPUtils.getString(Constants.SP_TEST_FLAVOR_CHANNEL, channel)
        }
        return channel
    }
}