Commit a9546cc2 authored by mengcuiguang2's avatar mengcuiguang2

代码优化

parent 32253ee1
...@@ -448,20 +448,16 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -448,20 +448,16 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
var vipDialog: VipDialog? = null var vipDialog: VipDialog? = null
private fun vipDialog() { private fun vipDialog() {
vipDialog = VipDialog(requireContext(), object : DialogListener() { vipDialog = VipDialog(requireContext(), object : VipDialog.VipStatusListener {
@SuppressLint("NonConstantResourceId") override fun close() {
override fun onClick(v: View) { onFragmentResume()
when (v.id) { }
// R.id.btn_dialogper_next -> {
// if (vipDialog != null && vipDialog!!.isShowing) { override fun paySuccess() {
// vipDialog!!.dismiss() onFragmentResume()
// } }
// AppPreferencesManager.get().put(Constant.LOAN_PERMISSION_FLAG, false)
// baseApplication.thirdConfig() override fun payFail() {
// TrackManager.getInstance().visitorlogin()
// initData()
// }
}
} }
}) })
vipDialog!!.show() vipDialog!!.show()
......
...@@ -28,6 +28,7 @@ import com.duben.heliapp.mvp.presenters.VipPresenter ...@@ -28,6 +28,7 @@ import com.duben.heliapp.mvp.presenters.VipPresenter
import com.duben.heliapp.mvp.views.VipView import com.duben.heliapp.mvp.views.VipView
import com.duben.heliapp.ui.activitys.VipActivity import com.duben.heliapp.ui.activitys.VipActivity
import com.duben.heliapp.ui.activitys.WebActivity import com.duben.heliapp.ui.activitys.WebActivity
import com.duben.heliapp.ui.adapter.TopAdapter
import com.duben.heliapp.ui.adapter.VipAdapter import com.duben.heliapp.ui.adapter.VipAdapter
import com.duben.heliapp.utils.BubbleUtils import com.duben.heliapp.utils.BubbleUtils
import com.duben.heliapp.utils.ForegroundOrBackground import com.duben.heliapp.utils.ForegroundOrBackground
...@@ -46,7 +47,7 @@ import com.jobo.wxpay.WXPayInfoImpl ...@@ -46,7 +47,7 @@ import com.jobo.wxpay.WXPayInfoImpl
*/ */
class VipDialog( class VipDialog(
context: Context, context: Context,
private val listener: DialogListener, private val listener: VipStatusListener,
val showPoint: Int? = 0 val showPoint: Int? = 0
) : ) :
Dialog(context, R.style.dialog), VipView, CompoundButton.OnCheckedChangeListener, Dialog(context, R.style.dialog), VipView, CompoundButton.OnCheckedChangeListener,
...@@ -62,6 +63,7 @@ class VipDialog( ...@@ -62,6 +63,7 @@ class VipDialog(
private var payType = VipActivity.WEIXIN_PAY// 支付类型 private var payType = VipActivity.WEIXIN_PAY// 支付类型
private var isCheckAgreeFlag: Boolean = true private var isCheckAgreeFlag: Boolean = true
lateinit var mOnVipStatusListener: VipStatusListener
private val lp: WindowManager.LayoutParams private val lp: WindowManager.LayoutParams
...@@ -167,6 +169,7 @@ class VipDialog( ...@@ -167,6 +169,7 @@ class VipDialog(
override fun queryVipOrderSuc(isPay: Boolean) { override fun queryVipOrderSuc(isPay: Boolean) {
if (isPay) { if (isPay) {
mOnVipStatusListener?.paySuccess()
ToastUtil.show(context, "支付成功") ToastUtil.show(context, "支付成功")
dismiss() dismiss()
} }
...@@ -227,6 +230,7 @@ class VipDialog( ...@@ -227,6 +230,7 @@ class VipDialog(
when (v?.id) { when (v?.id) {
R.id.iv_vip_dialog_close -> { R.id.iv_vip_dialog_close -> {
mOnVipStatusListener?.close()
dismiss() dismiss()
} }
R.id.tvVipPay -> { R.id.tvVipPay -> {
...@@ -313,7 +317,7 @@ class VipDialog( ...@@ -313,7 +317,7 @@ class VipDialog(
override fun failed(code: Int, message: String?) { override fun failed(code: Int, message: String?) {
vipPresenter.queryVipOrder(wxParanBean.tid.toString(), false) vipPresenter.queryVipOrder(wxParanBean.tid.toString(), false)
mOnVipStatusListener?.payFail()
} }
override fun cancel() { override fun cancel() {
...@@ -353,6 +357,7 @@ class VipDialog( ...@@ -353,6 +357,7 @@ class VipDialog(
if (!TextUtils.isEmpty(message)) { if (!TextUtils.isEmpty(message)) {
showToast(message) showToast(message)
} }
mOnVipStatusListener?.payFail()
} }
override fun cancel() { override fun cancel() {
...@@ -386,4 +391,15 @@ class VipDialog( ...@@ -386,4 +391,15 @@ class VipDialog(
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
context.startActivity(intent) context.startActivity(intent)
} }
interface VipStatusListener {
fun close()
fun paySuccess()
fun payFail()
}
fun setOnVipStatusListener(listener: VipStatusListener) {
mOnVipStatusListener = listener
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment