|
@@ -9,6 +9,7 @@ import androidx.core.content.res.ResourcesCompat
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.alibaba.android.arouter.facade.annotation.Autowired
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
+import com.alibaba.android.arouter.utils.TextUtils
|
|
|
import com.blankj.utilcode.util.ToastUtils
|
|
|
import com.shanp.youqi.base.util.LogUtil
|
|
|
import com.shanp.youqi.base.view.CoreCallback
|
|
@@ -25,7 +26,7 @@ import com.shanp.youqi.core.utils.SP
|
|
|
import com.shanp.youqi.core.wallet.WalletCore
|
|
|
import com.shanp.youqi.wallet.R
|
|
|
import com.shanp.youqi.wallet.adapter.UBeanRechargeAdapter
|
|
|
-import com.shanp.youqi.wallet.databinding.ActivityUbeanRechargeDemoBinding
|
|
|
+import com.shanp.youqi.wallet.databinding.ActivityUbeanRechargeBinding
|
|
|
import me.jessyan.autosize.utils.AutoSizeUtils
|
|
|
import java.lang.ref.SoftReference
|
|
|
|
|
@@ -33,10 +34,14 @@ import java.lang.ref.SoftReference
|
|
|
@Route(path = RouterUrl.WALLET_RECHARGE_DEMO)
|
|
|
class UBeanRechargeDemoActivity : UChatActivity() {
|
|
|
|
|
|
- private lateinit var binding: ActivityUbeanRechargeDemoBinding
|
|
|
+ private lateinit var binding: ActivityUbeanRechargeBinding
|
|
|
|
|
|
private lateinit var mAdapter: UBeanRechargeAdapter
|
|
|
|
|
|
+ companion object {
|
|
|
+ const val ITEM_REFRESH_TYPE: Int = 1 //item 局部 刷新
|
|
|
+ }
|
|
|
+
|
|
|
@JvmField
|
|
|
@Autowired(name = "sign")
|
|
|
var sign = 0
|
|
@@ -44,11 +49,11 @@ class UBeanRechargeDemoActivity : UChatActivity() {
|
|
|
private var mUBean: UserUBean? = null //选中的礼物
|
|
|
|
|
|
|
|
|
- override fun getLayoutId() = R.layout.activity_ubean_recharge_demo
|
|
|
+ override fun getLayoutId() = R.layout.activity_ubean_recharge
|
|
|
|
|
|
|
|
|
override fun initEventAndData() {
|
|
|
- binding = ActivityUbeanRechargeDemoBinding.bind(contentView)
|
|
|
+ binding = ActivityUbeanRechargeBinding.bind(contentView)
|
|
|
|
|
|
titleBar()
|
|
|
|
|
@@ -62,12 +67,14 @@ class UBeanRechargeDemoActivity : UChatActivity() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 请求 U豆充值档位数据
|
|
|
private fun getData() {
|
|
|
|
|
|
execute(WalletCore.get().getUBeanList("android"), object : CoreCallback<List<UserUBean>>() {
|
|
|
override fun onSuccess(t: List<UserUBean>?) {
|
|
|
super.onSuccess(t)
|
|
|
+ if (t == null) return
|
|
|
mAdapter.setNewData(t)
|
|
|
}
|
|
|
|
|
@@ -88,8 +95,24 @@ class UBeanRechargeDemoActivity : UChatActivity() {
|
|
|
execute(WalletCore.get().rechargeAccountInfo, object : CoreCallback<RechargeAccountInfo>() {
|
|
|
override fun onSuccess(t: RechargeAccountInfo?) {
|
|
|
super.onSuccess(t)
|
|
|
- binding.tvUBeanSurplusValue.text = t?.beans?.toString()
|
|
|
- binding.tvUBeanBalanceDes.text = t?.des?.toString()
|
|
|
+ if (t == null) return
|
|
|
+
|
|
|
+ binding.tvUBeanSurplusValue.text = if (TextUtils.isEmpty(t.beans.toString())) "0" else t.beans.toString()
|
|
|
+
|
|
|
+ if (!TextUtils.isEmpty(t.des?.toString())) {
|
|
|
+ binding.tvUBeanBalanceDes.visibility = View.VISIBLE
|
|
|
+ binding.tvUBeanBalanceDes.text = t.des?.toString()
|
|
|
+ } else {
|
|
|
+ binding.tvUBeanBalanceDes.visibility = View.GONE
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (!TextUtils.isEmpty(t.tip?.toString())) {
|
|
|
+ binding.tvUBeanTip.visibility = View.VISIBLE
|
|
|
+ binding.tvUBeanTip.text = t.tip?.toString()
|
|
|
+ } else {
|
|
|
+ binding.tvUBeanTip.visibility = View.GONE
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -100,6 +123,7 @@ class UBeanRechargeDemoActivity : UChatActivity() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 绑定点击事件
|
|
|
private fun initClickListener() {
|
|
|
|
|
@@ -112,10 +136,10 @@ class UBeanRechargeDemoActivity : UChatActivity() {
|
|
|
val i = mAdapter.getmSelectPosition()
|
|
|
mAdapter.setSelectPosition(position)
|
|
|
|
|
|
- mAdapter.notifyItemChanged(i, 1)
|
|
|
- mAdapter.notifyItemChanged(position, 1)
|
|
|
+ mAdapter.notifyItemChanged(i, ITEM_REFRESH_TYPE)
|
|
|
+ mAdapter.notifyItemChanged(position, ITEM_REFRESH_TYPE)
|
|
|
|
|
|
- mUBean = mAdapter.getItem(position)!!
|
|
|
+ mUBean = mAdapter.getItem(position)
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -141,18 +165,17 @@ class UBeanRechargeDemoActivity : UChatActivity() {
|
|
|
return@run;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
if (binding.cbBeanAgreement.isChecked) {
|
|
|
if (mUBean == null) {
|
|
|
ToastUtils.showShort("请选择充值金额");
|
|
|
return@run;
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
ToastUtils.showShort("请勾选协议")
|
|
|
return@run;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
showPayDialog()
|
|
|
}
|
|
|
}
|