|
@@ -12,16 +12,24 @@ import android.view.WindowManager
|
|
|
import android.widget.Button
|
|
|
import android.widget.ImageView
|
|
|
import cn.yyxx.eyuangame.core.entity.ClickType
|
|
|
+import cn.yyxx.eyuangame.core.entity.ResultInfo
|
|
|
+import cn.yyxx.eyuangame.core.entity.SdkBackLoginInfo
|
|
|
import cn.yyxx.eyuangame.core.impl.SdkBridgeImpl
|
|
|
+import cn.yyxx.eyuangame.core.internal.IImplCallback
|
|
|
+import cn.yyxx.eyuangame.core.internal.IRequestCallback
|
|
|
+import cn.yyxx.eyuangame.core.network.SdkRequest
|
|
|
import cn.yyxx.eyuangame.core.ui.EventEditText
|
|
|
+import cn.yyxx.eyuangame.core.utils.EditTextUtils
|
|
|
import cn.yyxx.support.DensityUtils
|
|
|
import cn.yyxx.support.ResUtils
|
|
|
+import cn.yyxx.support.hawkeye.ToastUtils
|
|
|
+import org.json.JSONObject
|
|
|
|
|
|
/**
|
|
|
* @author #Suyghur.
|
|
|
* Created on 2021/12/23
|
|
|
*/
|
|
|
-class BindAccountContainer(context: Context) : Dialog(context) {
|
|
|
+class BindAccountContainer(context: Context, private val callback: IImplCallback) : Dialog(context) {
|
|
|
|
|
|
private lateinit var ivReturn: ImageView
|
|
|
private lateinit var eetAccount: EventEditText
|
|
@@ -94,11 +102,47 @@ class BindAccountContainer(context: Context) : Dialog(context) {
|
|
|
|
|
|
btnConfirm = findViewById(ResUtils.getResId(context, "yyxx_btn_confirm", "id"))
|
|
|
btnConfirm.apply {
|
|
|
- tag = ClickType.ACTION_CONFIRM
|
|
|
setOnClickListener {
|
|
|
-
|
|
|
+ callBindAccount()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun callBindAccount() {
|
|
|
+ val userName = eetAccount.editText.text.trim().toString()
|
|
|
+ val pwd = eetPwd.editText.text.trim().toString()
|
|
|
+
|
|
|
+ if (!EditTextUtils.filterAccount(userName)) {
|
|
|
+ ToastUtils.toastInfo(context, ResUtils.getResString(context, "yyxx_tips_account_format_error"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!EditTextUtils.filterPwd(pwd)) {
|
|
|
+ ToastUtils.toastInfo(context, ResUtils.getResString(context, "yyxx_tips_pwd_format_error"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ with(JSONObject()) {
|
|
|
+ put("uid", SdkBackLoginInfo.instance.userId)
|
|
|
+ put("login_type", SdkBackLoginInfo.instance.loginType)
|
|
|
+ put("uname", userName)
|
|
|
+ put("pwd", pwd)
|
|
|
+ SdkRequest.instance.bindAccount(context, this, object : IRequestCallback {
|
|
|
+ override fun onResponse(resultInfo: ResultInfo) {
|
|
|
+ if (resultInfo.code == 1) {
|
|
|
+ SdkBackLoginInfo.instance.hasBindAccount = true
|
|
|
+ ToastUtils.toastInfo(context, resultInfo.msg)
|
|
|
+ callback.onResult(0, resultInfo.msg)
|
|
|
+ dismiss()
|
|
|
+ } else {
|
|
|
+ ToastUtils.toastInfo(context, resultInfo.msg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|