Pu Zhibing
2025-12-11 ab0c19e49fabdb8cc6eea454ea455bce2efbb718
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
package com.igo.user.ui.mine
 
import android.text.method.HideReturnsTransformationMethod
import android.text.method.PasswordTransformationMethod
import android.widget.CheckedTextView
import android.widget.EditText
import android.widget.TextView
import cn.sinata.xldutils.utils.myToast
import com.igo.user.R
import com.igo.user.network.HttpManager
import com.igo.user.network.request
import com.igo.user.ui.TransparentStatusBarActivity
import org.jetbrains.anko.find
import org.jetbrains.anko.sdk27.coroutines.onClick
 
class ChangePwdActivity: TransparentStatusBarActivity() {
    override fun setContentView(): Int = R.layout.activity_change_pwd
    private val tv_hide by lazy { find<CheckedTextView>(R.id.tv_hide) }
    private val et_pwd by lazy { find<EditText>(R.id.et_pwd) }
    private val tv_action by lazy { find<TextView>(R.id.tv_action) }
 
    override fun initClick() {
        tv_hide.setOnClickListener {
            tv_hide.isChecked = !tv_hide.isChecked
            if (!tv_hide.isChecked)
                et_pwd.transformationMethod = PasswordTransformationMethod.getInstance()
            else
                et_pwd.transformationMethod = HideReturnsTransformationMethod.getInstance()
            et_pwd.setSelection(et_pwd.text.length)
        }
        tv_action.onClick {
            val s = et_pwd.text.toString().trim()
            if(s.length<6){
                myToast(getString(R.string.密码不能小于6位))
                return@onClick
            }
            HttpManager.updatePassword(s).request(this@ChangePwdActivity){ _, _->
                myToast(getString(R.string.密码设置成功))
                finish()
            }
        }
    }
 
    override fun initView() {
        title = getString(R.string.设置密码)
    }
}