lmw
2023-06-13 adf8013576cbdd12e5ebea8ff7e32baf5d558b27
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
package com.kuanzhai.user.ui.mine
 
import android.app.Activity
import android.text.Editable
import android.text.TextWatcher
import androidx.core.os.bundleOf
import cn.sinata.xldutils.utils.myToast
import com.kuanzhai.user.R
import com.kuanzhai.user.dialog.AlertDialog
import com.kuanzhai.user.network.HttpManager
import com.kuanzhai.user.network.request
import com.kuanzhai.user.ui.TransparentStatusBarActivity
import kotlinx.android.synthetic.main.activity_apply_credit.*
import java.lang.Exception
 
class ApplyCreditActivity : TransparentStatusBarActivity(), TextWatcher {
    override fun setContentView() = R.layout.activity_apply_credit
 
    override fun initClick() {
        tv_action.setOnClickListener {
            val moneyS = et_money.text.toString()
            var money = 0.0
            try {
                money = moneyS.toDouble()
            }catch (e:Exception){
                myToast("请输入正确的额度")
                return@setOnClickListener
            }
            if (money==0.0){
                myToast("额度不能为0")
                return@setOnClickListener
            }
            tv_action.isEnabled = false
            HttpManager.saveCompanyLimit(money,et_reason.text.toString()).request(this,success = {_,_->
                setResult(Activity.RESULT_OK)
                val alertDialog = AlertDialog()
                alertDialog.arguments = bundleOf("msg" to "提交成功!")
                alertDialog.setDismissCallback(object :AlertDialog.OnDismiss{
                    override fun onDismiss() {
                        finish()
                    }
                })
                alertDialog.show(supportFragmentManager,"apply")
            }){_,_->
                tv_action.isEnabled = true
            }
        }
    }
 
    override fun initView() {
        et_money.addTextChangedListener(this)
        et_reason.addTextChangedListener(this)
    }
 
    override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
    }
 
    override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
    }
 
    override fun afterTextChanged(s: Editable?) {
        tv_action.isEnabled = et_money.text.isNotEmpty()&&et_reason.text.isNotEmpty()
    }
 
}