package cn.yyxx.eyuancomm.comm.utils

import android.content.Context
import android.text.TextUtils
import cn.yyxx.support.PropertiesUtils

/**
 * @author #Suyghur.
 * Created on 2021/06/17
 */
object ParamsUtils {

    private const val CONFIG_FILE = "yyxx_comm.properties"

    private const val YYXX_COMM_GCP_CODE = "YYXX_COMM_GCP_CODE"
    private const val YYXX_COMM_GAME_CODE = "YYXX_COMM_GAME_CODE"
    private const val YYXX_CHANNEL_ID = "YYXX_CHANNEL_ID"

    @JvmStatic
    fun getCommGcpCode(context: Context): String {
        try {
            val code = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_COMM_GCP_CODE)
            if (!TextUtils.isEmpty(code)) {
                return code
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getCommGameCode(context: Context): String {
        try {
            val code = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_COMM_GAME_CODE)
            if (!TextUtils.isEmpty(code)) {
                return code
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }

    @JvmStatic
    fun getChannelId(context: Context): String {
        try {
            val channelId = PropertiesUtils.getValue4Properties(context, CONFIG_FILE, "yyxx_game", YYXX_CHANNEL_ID)
            if (!TextUtils.isEmpty(channelId)) {
                return channelId
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return ""
    }
}