|
@@ -1,43 +1,35 @@
|
|
|
-package cn.yyxx.eyuangame.core.impl.center.fragment
|
|
|
+package cn.yyxx.eyuangame.core.impl.center
|
|
|
|
|
|
+import android.app.Dialog
|
|
|
import android.content.Context
|
|
|
import android.graphics.Color
|
|
|
-import android.os.Bundle
|
|
|
+import android.graphics.drawable.ColorDrawable
|
|
|
import android.os.Handler
|
|
|
import android.os.Looper
|
|
|
import android.os.Message
|
|
|
import android.text.TextUtils
|
|
|
-import android.view.Gravity
|
|
|
-import android.view.LayoutInflater
|
|
|
-import android.view.View
|
|
|
-import android.view.ViewGroup
|
|
|
+import android.view.*
|
|
|
import android.widget.*
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
-import androidx.fragment.app.Fragment
|
|
|
import cn.yyxx.eyuangame.base.utils.Logger
|
|
|
-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.impl.center.MemberActivity
|
|
|
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.eyuangame.core.utils.TimeDownUtils
|
|
|
+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/06/30
|
|
|
+ * Created on 2021/12/23
|
|
|
*/
|
|
|
-class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
-
|
|
|
- private lateinit var mView: View
|
|
|
- private lateinit var memberImpl: MemberActivity
|
|
|
-
|
|
|
+class BindPhoneContainer(context: Context) : Dialog(context) {
|
|
|
private lateinit var llGroup1: LinearLayout
|
|
|
private lateinit var llGroup2: LinearLayout
|
|
|
private lateinit var clTips: ConstraintLayout
|
|
@@ -70,62 +62,71 @@ class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
|
- super.onCreateView(inflater, container, savedInstanceState)
|
|
|
- memberImpl = requireActivity() as MemberActivity
|
|
|
- mView = layoutInflater.inflate(ResUtils.getResId(requireActivity(), "yyxx_member_bind_phone", "layout"), container, false)
|
|
|
- initView(mView)
|
|
|
- return mView
|
|
|
+ init {
|
|
|
+ setCanceledOnTouchOutside(true)
|
|
|
+ window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
|
|
+ requestWindowFeature(Window.FEATURE_NO_TITLE)
|
|
|
+ initView(context)
|
|
|
}
|
|
|
|
|
|
- private fun initView(view: View) {
|
|
|
+ private fun initView(context: Context) {
|
|
|
+ setContentView(ResUtils.getResId(context, "yyxx_member_bind_phone", "layout"))
|
|
|
+
|
|
|
+ val attr = window?.attributes as WindowManager.LayoutParams
|
|
|
+ attr.height = DensityUtils.dip2px(context, 250f)
|
|
|
+ if (SdkBridgeImpl.isLand) {
|
|
|
+ attr.width = DensityUtils.getHeightAndWidth(context)[0] / 2
|
|
|
+ } else {
|
|
|
+ attr.width = DensityUtils.getHeightAndWidth(context)[0] - 80
|
|
|
+ }
|
|
|
+ attr.gravity = Gravity.CENTER
|
|
|
|
|
|
imgUp = ResUtils.getResId(context, "yyxx_pack_up_white_img", "drawable")
|
|
|
imgDown = ResUtils.getResId(context, "yyxx_pack_down_white_img", "drawable")
|
|
|
|
|
|
- ivReturn = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_iv_return", "id"))
|
|
|
- ivReturn.apply {
|
|
|
- tag = ClickType.ACTION_RETURN
|
|
|
- setOnClickListener(this@BindPhoneFragment)
|
|
|
+ ivReturn = findViewById(ResUtils.getResId(context, "yyxx_iv_return", "id"))
|
|
|
+
|
|
|
+ ivReturn.setOnClickListener {
|
|
|
+ dismiss()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- llGroup1 = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_ll_group1", "id"))
|
|
|
- llGroup2 = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_ll_group2", "id"))
|
|
|
- clTips = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_cl_tips", "id"))
|
|
|
+ llGroup1 = findViewById(ResUtils.getResId(context, "yyxx_ll_group1", "id"))
|
|
|
+ llGroup2 = findViewById(ResUtils.getResId(context, "yyxx_ll_group2", "id"))
|
|
|
+ clTips = findViewById(ResUtils.getResId(context, "yyxx_cl_tips", "id"))
|
|
|
|
|
|
- eetPhone = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_eet_phone", "id"))
|
|
|
- eetPhone.editText.hint = ResUtils.getResString(requireActivity(), "yyxx_hint_forget_phone")
|
|
|
+ eetPhone = findViewById(ResUtils.getResId(context, "yyxx_eet_phone", "id"))
|
|
|
+ eetPhone.editText.hint = ResUtils.getResString(context, "yyxx_hint_forget_phone")
|
|
|
|
|
|
- eetCaptcha = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_eet_captcha", "id"))
|
|
|
- eetCaptcha.editText.hint = ResUtils.getResString(requireActivity(), "yyxx_hint_bind_phone_captcha")
|
|
|
+ eetCaptcha = findViewById(ResUtils.getResId(context, "yyxx_eet_captcha", "id"))
|
|
|
+ eetCaptcha.editText.hint = ResUtils.getResString(context, "yyxx_hint_bind_phone_captcha")
|
|
|
|
|
|
- btnCaptCha = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_btn_captcha", "id"))
|
|
|
- btnCaptCha.apply {
|
|
|
- tag = ClickType.ACTION_GET_CAPTCHA
|
|
|
- setOnClickListener(this@BindPhoneFragment)
|
|
|
+ btnCaptCha = findViewById(ResUtils.getResId(context, "yyxx_btn_captcha", "id"))
|
|
|
+ btnCaptCha.setOnClickListener {
|
|
|
+ callGetCaptcha()
|
|
|
}
|
|
|
|
|
|
- btnConfirm = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_btn_confirm", "id"))
|
|
|
- btnConfirm.apply {
|
|
|
- tag = ClickType.ACTION_CONFIRM
|
|
|
- setOnClickListener(this@BindPhoneFragment)
|
|
|
+
|
|
|
+ btnConfirm = findViewById(ResUtils.getResId(context, "yyxx_btn_confirm", "id"))
|
|
|
+ btnConfirm.setOnClickListener {
|
|
|
+ callBindPhone()
|
|
|
}
|
|
|
|
|
|
- rlAreaList = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_rl_area_list", "id"))
|
|
|
+ rlAreaList = findViewById(ResUtils.getResId(context, "yyxx_rl_area_list", "id"))
|
|
|
rlAreaList.visibility = View.GONE
|
|
|
- llAreaList = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_ll_area_list", "id"))
|
|
|
- svAreaList = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_sv_area_list", "id"))
|
|
|
+ llAreaList = findViewById(ResUtils.getResId(context, "yyxx_ll_area_list", "id"))
|
|
|
+ svAreaList = findViewById(ResUtils.getResId(context, "yyxx_sv_area_list", "id"))
|
|
|
|
|
|
|
|
|
- tvArea = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_tv_area", "id"))
|
|
|
- ivArrow = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_iv_arrow", "id"))
|
|
|
+ tvArea = findViewById(ResUtils.getResId(context, "yyxx_tv_area", "id"))
|
|
|
+ ivArrow = findViewById(ResUtils.getResId(context, "yyxx_iv_arrow", "id"))
|
|
|
ivArrow.setOnClickListener {
|
|
|
changeAreaList()
|
|
|
}
|
|
|
|
|
|
- autoFillAreaList(requireActivity())
|
|
|
+ autoFillAreaList(context)
|
|
|
|
|
|
- tvBindTips = view.findViewById(ResUtils.getResId(requireActivity(), "yyxx_tv_tips2", "id"))
|
|
|
+ tvBindTips = findViewById(ResUtils.getResId(context, "yyxx_tv_tips2", "id"))
|
|
|
val tipsPhone = if (SdkBackLoginInfo.instance.phoneNum.length > 6) {
|
|
|
val head = SdkBackLoginInfo.instance.phoneNum.substring(0, 3)
|
|
|
val foot = SdkBackLoginInfo.instance.phoneNum.substring(SdkBackLoginInfo.instance.phoneNum.length - 3, SdkBackLoginInfo.instance.phoneNum.length)
|
|
@@ -133,7 +134,9 @@ class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
} else {
|
|
|
SdkBackLoginInfo.instance.phoneNum
|
|
|
}
|
|
|
- tvBindTips.text = "${ResUtils.getResString(requireActivity(), "yyxx_iv_bind_phone_tips2")}$tipsPhone"
|
|
|
+ tvBindTips.text = "${ResUtils.getResString(context, "yyxx_iv_bind_phone_tips2")}$tipsPhone"
|
|
|
+
|
|
|
+ showOrHideTips()
|
|
|
}
|
|
|
|
|
|
private fun autoFillAreaList(context: Context) {
|
|
@@ -218,13 +221,13 @@ class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
Logger.d("$areaCode ...")
|
|
|
val phoneNum = eetPhone.editText.text.trim().toString()
|
|
|
|
|
|
- if (TextUtils.isEmpty(areaCode) || areaCode == ResUtils.getResString(requireActivity(), "yyxx_tv_area_code")) {
|
|
|
- ToastUtils.toastInfo(requireActivity(), ResUtils.getResString(requireActivity(), "yyxx_tips_area_code_format_error"))
|
|
|
+ if (TextUtils.isEmpty(areaCode) || areaCode == ResUtils.getResString(context, "yyxx_tv_area_code")) {
|
|
|
+ ToastUtils.toastInfo(context, ResUtils.getResString(context, "yyxx_tips_area_code_format_error"))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if (!EditTextUtils.filterPwd(phoneNum)) {
|
|
|
- ToastUtils.toastInfo(requireActivity(), ResUtils.getResString(requireActivity(), "yyxx_tips_phone_format_error"))
|
|
|
+ ToastUtils.toastInfo(context, ResUtils.getResString(context, "yyxx_tips_phone_format_error"))
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -233,13 +236,13 @@ class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
put("sms_type", "bind_phone")
|
|
|
put("area_code", areaCode)
|
|
|
put("phone_number", phoneNum)
|
|
|
- SdkRequest.instance.getCaptcha(requireActivity(), this, object : IRequestCallback {
|
|
|
+ SdkRequest.instance.getCaptcha(context, this, object : IRequestCallback {
|
|
|
override fun onResponse(resultInfo: ResultInfo) {
|
|
|
if (resultInfo.code == 1) {
|
|
|
- ToastUtils.toastInfo(requireActivity(), resultInfo.msg)
|
|
|
+ ToastUtils.toastInfo(context, resultInfo.msg)
|
|
|
changeTimeNum()
|
|
|
} else {
|
|
|
- ToastUtils.toastInfo(requireActivity(), resultInfo.msg)
|
|
|
+ ToastUtils.toastInfo(context, resultInfo.msg)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -254,11 +257,11 @@ class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
val captcha = eetCaptcha.editText.text.trim().toString()
|
|
|
|
|
|
if (TextUtils.isEmpty(captcha)) {
|
|
|
- ToastUtils.toastInfo(requireActivity(), ResUtils.getResString(requireActivity(), "yyxx_tips_captcha_format_error"))
|
|
|
+ ToastUtils.toastInfo(context, ResUtils.getResString(context, "yyxx_tips_captcha_format_error"))
|
|
|
return
|
|
|
}
|
|
|
if (!EditTextUtils.filterPhone(phoneNum)) {
|
|
|
- ToastUtils.toastInfo(requireActivity(), ResUtils.getResString(requireActivity(), "yyxx_tips_phone_format_error"))
|
|
|
+ ToastUtils.toastInfo(context, ResUtils.getResString(context, "yyxx_tips_phone_format_error"))
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -267,14 +270,14 @@ class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
put("uid", SdkBackLoginInfo.instance.userId)
|
|
|
put("phone_number", phoneNum)
|
|
|
put("sms_code", captcha)
|
|
|
- SdkRequest.instance.bindPhone(requireActivity(), this, object : IRequestCallback {
|
|
|
+ SdkRequest.instance.bindPhone(context, this, object : IRequestCallback {
|
|
|
override fun onResponse(resultInfo: ResultInfo) {
|
|
|
if (resultInfo.code == 1) {
|
|
|
SdkBackLoginInfo.instance.phoneNum = phoneNum
|
|
|
- ToastUtils.toastInfo(requireActivity(), resultInfo.msg)
|
|
|
- requireActivity().onBackPressed()
|
|
|
+ ToastUtils.toastInfo(context, resultInfo.msg)
|
|
|
+ dismiss()
|
|
|
} else {
|
|
|
- ToastUtils.toastInfo(requireActivity(), resultInfo.msg)
|
|
|
+ ToastUtils.toastInfo(context, resultInfo.msg)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -288,7 +291,7 @@ class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
btnCaptCha.apply {
|
|
|
text = if (time <= 0) {
|
|
|
this.isEnabled = true
|
|
|
- ResUtils.getResString(requireActivity(), "yyxx_tv_get_captcha")
|
|
|
+ ResUtils.getResString(context, "yyxx_tv_get_captcha")
|
|
|
} else {
|
|
|
this.isEnabled = false
|
|
|
"${time}s"
|
|
@@ -332,26 +335,6 @@ class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- override fun onResume() {
|
|
|
- super.onResume()
|
|
|
- showOrHideTips()
|
|
|
- }
|
|
|
-
|
|
|
- override fun onDestroy() {
|
|
|
- super.onDestroy()
|
|
|
- areaCodeList.clear()
|
|
|
- rlAreaList.visibility = View.GONE
|
|
|
- }
|
|
|
-
|
|
|
- override fun onClick(v: View?) {
|
|
|
- v?.apply {
|
|
|
- when (tag as Int) {
|
|
|
- ClickType.ACTION_RETURN -> requireActivity().onBackPressed()
|
|
|
- ClickType.ACTION_GET_CAPTCHA -> callGetCaptcha()
|
|
|
- ClickType.ACTION_CONFIRM -> callBindPhone()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 账号列表item点击事件
|
|
@@ -361,7 +344,7 @@ class BindPhoneFragment : Fragment(), View.OnClickListener {
|
|
|
tvArea.apply {
|
|
|
changeAreaList()
|
|
|
tvArea.text = areaCode
|
|
|
- this@BindPhoneFragment.code = areaCode
|
|
|
+ this@BindPhoneContainer.code = areaCode
|
|
|
}
|
|
|
}
|
|
|
}
|