lmw
2023-06-20 7e4a923b472a1ffb9d6deeb80302551ba4178ca3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.fanghua.driver.ui.mine.money_bag
 
import cn.sinata.xldutils.utils.visible
import com.fanghua.driver.R
import com.fanghua.driver.base.BaseEvent
import com.fanghua.driver.base.MyBaseActivity
import kotlinx.android.synthetic.main.activity_my_qr_code.*
import org.greenrobot.eventbus.Subscribe
import org.jetbrains.anko.startActivity
 
class MyQrCodeActivity : MyBaseActivity() {
    override fun setContentView() {
        setContentView(R.layout.activity_my_qr_code)
    }
 
    private var wx = ""
    private var ali = ""
 
    override fun initView() {
        setTitleText("收款码")
        wx = intent.getStringExtra("wx")?:""
        ali = intent.getStringExtra("ali")?:""
        refreshUi()
    }
 
    private fun refreshUi() {
        if (wx.isNotEmpty() && ali.isNotEmpty()) {
            tv_1.text = "微信"
            tv_code_1.text = "已设置"
            tv_2.text = "支付宝"
            tv_code_2.text = "已设置"
        } else if (wx.isNotEmpty()) {
            tv_1.text = "微信"
            tv_code_1.text = "已设置"
            tv_2.text = "支付宝"
        } else if (ali.isNotEmpty()) {
            tv_1.text = "支付宝"
            tv_code_1.text = "已设置"
            tv_2.text = "微信"
        }
        if (!(wx.isEmpty()&&ali.isEmpty())){
            tv_2.visible()
            tv_code_2.visible()
            line.visible()
        }
    }
 
    override fun setOnclick() {
        tv_code_1.setOnClickListener {
            if (tv_1.text == "收款码"){
                startActivity<AddPayQRCodeActivity>()
            }else{
                val way = tv_1.text.toString()
                startActivity<UpQrCodeActivity>("code" to (if (way == "微信") wx else ali),"way" to way)
            }
        }
 
        tv_code_2.setOnClickListener {
            if (tv_code_2.text.isEmpty()){
                startActivity<AddPayQRCodeActivity>("way" to tv_2.text.toString())
            }else{
                val way = tv_2.text.toString()
                startActivity<UpQrCodeActivity>("code" to (if (way == "微信") wx else ali),"way" to way)
            }
        }
    }
 
    @Subscribe
    fun onCodeChange(e:BaseEvent){
        if (e.code == BaseEvent.CODE_CHANGE){
            if (e.msg == "zfbCollectionCode")
                ali = e.msgTwo
            else
                wx = e.msgTwo
            refreshUi()
        }
    }
 
}