|
@@ -14,6 +14,8 @@ import cn.yyxx.eyuangame.base.utils.ParamsUtils
|
|
|
import cn.yyxx.eyuangame.core.entity.ResultInfo
|
|
|
import cn.yyxx.eyuangame.core.entity.SdkBackLoginInfo
|
|
|
import cn.yyxx.eyuangame.core.entity.bean.init.InitBean
|
|
|
+import cn.yyxx.eyuangame.core.impl.floating.FloatCenterServiceManager
|
|
|
+import cn.yyxx.eyuangame.core.impl.iab.ChargeImpl
|
|
|
import cn.yyxx.eyuangame.core.impl.login.LoginActivity
|
|
|
import cn.yyxx.eyuangame.core.internal.IImplCallback
|
|
|
import cn.yyxx.eyuangame.core.internal.IRequestCallback
|
|
@@ -21,6 +23,7 @@ import cn.yyxx.eyuangame.core.network.Host
|
|
|
import cn.yyxx.eyuangame.core.network.SdkRequest
|
|
|
import cn.yyxx.eyuangame.core.ui.dialog.TipsDialog
|
|
|
import cn.yyxx.eyuangame.core.utils.MMKVUtils
|
|
|
+import cn.yyxx.support.BeanUtils
|
|
|
import cn.yyxx.support.DensityUtils
|
|
|
import cn.yyxx.support.ResUtils
|
|
|
import cn.yyxx.support.device.DeviceInfoUtils
|
|
@@ -68,7 +71,7 @@ class SdkBridgeImpl(context: Context) {
|
|
|
fun attachBaseContext(application: Application, context: Context) {
|
|
|
Logger.initZap(application)
|
|
|
SdkDrive.instance.initSdkDrive(application)
|
|
|
- Logger.i("Columbus attachBaseContext ...")
|
|
|
+ Logger.i("EYuanGameSdk attachBaseContext ...")
|
|
|
GAIDUtils.initGoogleAdid(application) { code, _ ->
|
|
|
if (code == 0) {
|
|
|
Logger.i("谷歌框架可以访问,请求gaid")
|
|
@@ -82,13 +85,14 @@ class SdkBridgeImpl(context: Context) {
|
|
|
}
|
|
|
|
|
|
fun initApplication(application: Application) {
|
|
|
- Logger.i("Columbus initApplication ...")
|
|
|
+ Logger.i("EYuanGameSdk initApplication ...")
|
|
|
MMKVUtils.instance.init(application)
|
|
|
}
|
|
|
|
|
|
fun initialize(activity: Activity, isLandscape: Boolean, callback: ICallback, initCallback: IInitialize) {
|
|
|
- Logger.i("Columbus initialize ...")
|
|
|
+ Logger.i("EYuanGameSdk initialize ...")
|
|
|
isLand = isLandscape
|
|
|
+ this.mActivity = activity
|
|
|
if (TextUtils.isEmpty(ParamsUtils.getGcpCode(activity))) {
|
|
|
Logger.e("初始化失败,参数异常,请检查yyxx_cfg.properties中YYXX_GCP_CODE的值")
|
|
|
initCallback.onResult(-1, "初始化失败,参数异常,请检查yyxx_cfg.properties中YYXX_GAME_CODE的值")
|
|
@@ -149,6 +153,7 @@ class SdkBridgeImpl(context: Context) {
|
|
|
initBean = InitBean.toBean(resultInfo.data)
|
|
|
//TODO 下载图片资源
|
|
|
showInitDialog(activity, callback, initCallback)
|
|
|
+ FloatCenterServiceManager.instance.init(activity)
|
|
|
} else {
|
|
|
initState = false
|
|
|
initCallback.onResult(-1, "SDK初始化失败")
|
|
@@ -166,6 +171,7 @@ class SdkBridgeImpl(context: Context) {
|
|
|
}
|
|
|
|
|
|
fun login(activity: Activity, isAutoLogin: Boolean, callback: ICallback) {
|
|
|
+ Logger.i("EYuanGameSdk login ...")
|
|
|
this.mActivity = activity
|
|
|
if (!initState) {
|
|
|
Logger.e("登录失败,SDK未初始化或初始化失败")
|
|
@@ -216,6 +222,7 @@ class SdkBridgeImpl(context: Context) {
|
|
|
}
|
|
|
|
|
|
fun logout(activity: Activity, callback: ICallback) {
|
|
|
+ Logger.i("EYuanGameSdk logout ...")
|
|
|
this.mActivity = activity
|
|
|
this.roleInfo = null
|
|
|
SdkBackLoginInfo.instance.reset()
|
|
@@ -223,27 +230,64 @@ class SdkBridgeImpl(context: Context) {
|
|
|
}
|
|
|
|
|
|
fun charge(activity: Activity, chargeInfo: SdkChargeInfo, callback: ICallback) {
|
|
|
+ Logger.i("EYuanGameSdk charge ...")
|
|
|
this.mActivity = activity
|
|
|
if (!initState) {
|
|
|
Logger.e("支付失败,SDK未初始化或初始化失败")
|
|
|
callback.onResult(-1, "支付失败,SDK未初始化或初始化失败")
|
|
|
return
|
|
|
}
|
|
|
+ if (TextUtils.isEmpty(SdkBackLoginInfo.instance.userId)) {
|
|
|
+ Logger.e("支付失败,用户未登录或登录失败")
|
|
|
+ callback.onResult(-1, "支付失败,用户未登录或登录失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!isSubmitRoleData) {
|
|
|
+ Logger.e("支付失败,角色未登录或登录失败")
|
|
|
+ callback.onResult(-1, "支付失败,角色未登录或登录失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!DeviceInfoUtils.isNetworkConnected(activity)) {
|
|
|
+ Logger.e("当前网络连接异常,请重试")
|
|
|
+ callback.onResult(-1, "当前网络连接异常,请重试")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ val innerChargeInfo = BeanUtils.deepClone(chargeInfo)
|
|
|
+ if (innerChargeInfo == null) {
|
|
|
+ Logger.e("支付失败,支付信息对象拷贝过程异常")
|
|
|
+ callback.onResult(-1, "支付失败,支付信息对象拷贝过程异常")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ChargeImpl.instance.charge(activity, innerChargeInfo, object : IImplCallback {
|
|
|
+ override fun onResult(code: Int, result: String) {
|
|
|
+ callback.onResult(code, result)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
fun roleCreate(activity: Activity, roleInfo: SdkRoleInfo) {
|
|
|
+ Logger.i("EYuanGameSdk roleCreate ...")
|
|
|
+ this.mActivity = activity
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
fun roleLauncher(activity: Activity, roleInfo: SdkRoleInfo) {
|
|
|
+ Logger.i("EYuanGameSdk roleLauncher ...")
|
|
|
+ this.mActivity = activity
|
|
|
|
|
|
}
|
|
|
|
|
|
fun roleLevelUp(activity: Activity, roleInfo: SdkRoleInfo) {
|
|
|
+ Logger.i("EYuanGameSdk roleLevelUp ...")
|
|
|
+ this.mActivity = activity
|
|
|
|
|
|
}
|
|
|
|
|
|
fun openExitView(activity: Activity, callback: ICallback) {
|
|
|
+ Logger.i("EYuanGameSdk openExitView ...")
|
|
|
+ this.mActivity = activity
|
|
|
exitDialog?.apply {
|
|
|
dismiss()
|
|
|
exitDialog = null
|
|
@@ -273,47 +317,62 @@ class SdkBridgeImpl(context: Context) {
|
|
|
}
|
|
|
|
|
|
fun onStart(activity: Activity) {
|
|
|
+ Logger.i("EYuanGameSdk onStart ...")
|
|
|
+ this.mActivity = activity
|
|
|
|
|
|
}
|
|
|
|
|
|
fun onRestart(activity: Activity) {
|
|
|
+ Logger.i("EYuanGameSdk onRestart ...")
|
|
|
+ this.mActivity = activity
|
|
|
|
|
|
}
|
|
|
|
|
|
fun onResume(activity: Activity) {
|
|
|
+ Logger.i("EYuanGameSdk onResume ...")
|
|
|
+ this.mActivity = activity
|
|
|
+ FloatCenterServiceManager.instance.show()
|
|
|
|
|
|
}
|
|
|
|
|
|
fun onPause(activity: Activity) {
|
|
|
+ Logger.i("EYuanGameSdk onPause ...")
|
|
|
+ this.mActivity = activity
|
|
|
+ FloatCenterServiceManager.instance.hide()
|
|
|
|
|
|
}
|
|
|
|
|
|
fun onStop(activity: Activity) {
|
|
|
-
|
|
|
+ Logger.i("EYuanGameSdk onStop ...")
|
|
|
+ this.mActivity = activity
|
|
|
}
|
|
|
|
|
|
fun onDestroy(activity: Activity) {
|
|
|
-
|
|
|
+ Logger.i("EYuanGameSdk onDestroy ...")
|
|
|
+ this.mActivity = activity
|
|
|
+ FloatCenterServiceManager.instance.release()
|
|
|
}
|
|
|
|
|
|
fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, intent: Intent) {
|
|
|
+ Logger.i("EYuanGameSdk onActivityResult ...")
|
|
|
+ this.mActivity = activity
|
|
|
|
|
|
}
|
|
|
|
|
|
fun onNewIntent(activity: Activity, intent: Intent) {
|
|
|
+ Logger.i("EYuanGameSdk onNewIntent ...")
|
|
|
+ this.mActivity = activity
|
|
|
|
|
|
}
|
|
|
|
|
|
fun getCurrentUserId(): String {
|
|
|
+ Logger.i("EYuanGameSdk getCurrentUserId ...")
|
|
|
return SdkBackLoginInfo.instance.userId
|
|
|
}
|
|
|
|
|
|
companion object {
|
|
|
-
|
|
|
var isLand = false
|
|
|
-
|
|
|
lateinit var initBean: InitBean
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|