Commit 5e296a17 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 4860ce9b
......@@ -254,10 +254,10 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
//0 app内部,1.只签约转支付宝浏览器支付 2.带uid转支付宝小程序(暂定只有一个小程序)
when (payToModel) {
0 -> {
wxPay(paramsBean,payToModel)
wxPay(paramsBean, payToModel)
}
1 -> {
wxPay(paramsBean,payToModel)
wxPay(paramsBean, payToModel)
}
}
}
......@@ -348,22 +348,21 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
vipAdapter.setPosition(0)
vipAdapter.notifyDataSetChanged()
val vipBean = vipList!![0]
if (TextUtils.equals(payType, "WEIXIN")) {
if (TextUtils.equals(payType, WEIXIN_PAY)) {
ll_vip_alipay.visibility = View.GONE
ll_vip_wx.visibility = View.VISIBLE
payType = WEIXIN_PAY
iv_vip_wx.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_none)
}else{
if (vipBean.trial == 1) {
ll_vip_alipay.visibility = View.VISIBLE
ll_vip_wx.visibility = View.GONE
payType = ALIPAY
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_wx.setImageResource(R.mipmap.ic_vip_none)
}
} else {
ll_vip_alipay.visibility = View.VISIBLE
ll_vip_wx.visibility = View.GONE
payType = ALIPAY
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_wx.setImageResource(R.mipmap.ic_vip_none)
}
val vipBean = vipList!![0]
backPayYesDialog(vipBean)
return true
}
......@@ -385,14 +384,18 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
vipAdapter.setPosition(0)
vipAdapter.notifyDataSetChanged()
val vipBean = vipList!![0]
if (vipBean.trial == 1) {
if (TextUtils.equals(payType, WEIXIN_PAY)) {
ll_vip_alipay.visibility = View.GONE
ll_vip_wx.visibility = View.VISIBLE
payType = WEIXIN_PAY
iv_vip_wx.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_none)
} else {
ll_vip_alipay.visibility = View.VISIBLE
ll_vip_wx.visibility = View.GONE
payType = ALIPAY
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_wx.setImageResource(R.mipmap.ic_vip_none)
} else {
payType = ALIPAY
}
backPayYesDialog(vipBean)
} else {
......@@ -476,7 +479,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
}
}
fun wxPay(wxParanBean: WxPayParamBean,payToModel:Int) {
fun wxPay(wxParanBean: WxPayParamBean, payToModel: Int) {
val data = wxParanBean.params
//实例化微信支付策略
val wxPay: WXPay = WXPay.getInstance()
......@@ -628,7 +631,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
private fun ruleAgreementPayDialog() {
if (vipList != null && vipList!!.size > 0) {
val vipBean = vipList!![vipAdapter.getPosition()]
ruleAgreementDialog = RuleAgreementDialog(context, object : DialogListener() {
ruleAgreementDialog = RuleAgreementDialog(context,payType, object : DialogListener() {
override fun onClick(v: View) {
if (!isFinishing() && ruleAgreementDialog != null && ruleAgreementDialog!!.isShowing()) {
ruleAgreementDialog!!.dismiss()
......
......@@ -3,6 +3,7 @@ package com.duben.miaoquplaylet.ui.widgets
import android.app.Dialog
import android.content.Context
import android.os.Handler
import android.text.TextUtils
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
......@@ -12,13 +13,19 @@ import android.widget.TextView
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.duben.miaoquplaylet.R
import com.duben.miaoquplaylet.ui.activitys.VipActivity
import com.duben.miaoquplaylet.ui.widgets.countdowntimer.CountDownTimerSupport
import com.duben.miaoquplaylet.ui.widgets.countdowntimer.OnCountDownTimerListener
import com.duben.miaoquplaylet.utils.SpanUtils
import com.duben.miaoquplaylet.utils.TimeRender
import kotlinx.android.synthetic.main.activity_new_vip.*
import java.util.*
class RuleAgreementDialog(private val context: Context, private val listener: DialogListener) :
class RuleAgreementDialog(
private val context: Context,
val payType: String,
private val listener: DialogListener
) :
Dialog(
context, R.style.dialog
) {
......@@ -27,6 +34,7 @@ class RuleAgreementDialog(private val context: Context, private val listener: Di
private val tv_agreement_next: TextView
private val tv_rule_date1: TextView
private val tv_rule_date2: TextView
private val tv_rule_name: TextView
var timer: CountDownTimerSupport? = null
init {
......@@ -52,6 +60,7 @@ class RuleAgreementDialog(private val context: Context, private val listener: Di
iv_agreement_quit = findViewById<View>(R.id.iv_agreement_quit) as ImageView
tv_rule_date1 = findViewById<View>(R.id.tv_rule_date1) as TextView
tv_rule_date2 = findViewById<View>(R.id.tv_rule_date2) as TextView
tv_rule_name = findViewById<View>(R.id.tv_rule_name) as TextView
iv_agreement_quit.setOnClickListener(listener)
tv_agreement_next.setOnClickListener(listener)
......@@ -59,7 +68,13 @@ class RuleAgreementDialog(private val context: Context, private val listener: Di
startTimer()
}, 200)
if (TextUtils.equals(payType, VipActivity.WEIXIN_PAY)) {
tv_rule_name.text = "微信支付"
tv_rule_name.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_call_wx,0,0,0)
} else {
tv_rule_name.text = "支付宝支付"
tv_rule_name.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_alipay,0,0,0)
}
}
......@@ -97,13 +112,13 @@ class RuleAgreementDialog(private val context: Context, private val listener: Di
timer!!.start()
}
fun setText(remarks: String,days:Int,cash:Double,title: String) {
tv_rule_date2.text = TimeRender.getDateAfter(Date(),days) + ":" + remarks
fun setText(remarks: String, days: Int, cash: Double, title: String) {
tv_rule_date2.text = TimeRender.getDateAfter(Date(), days) + ":" + remarks
SpanUtils.with(tv_rule_date1)
.append(TimeRender.formatDateDot(Date()))
.append(": ")
.append("${cash}元开启${title}体验")
.setForegroundColor(context.resources.getColor(R.color.main_mints))
.create()
.append(TimeRender.formatDateDot(Date()))
.append(": ")
.append("${cash}元开启${title}体验")
.setForegroundColor(context.resources.getColor(R.color.main_mints))
.create()
}
}
\ No newline at end of file
......@@ -156,6 +156,7 @@
android:orientation="horizontal">
<TextView
android:id="@+id/tv_rule_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@mipmap/ic_alipay"
......
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