| | |
| | | import android.text.Editable |
| | | import android.text.TextWatcher |
| | | import android.view.KeyEvent |
| | | import android.view.MotionEvent |
| | | import android.view.inputmethod.InputMethodManager |
| | | import androidx.core.os.bundleOf |
| | | import cn.sinata.xldutils.utils.SpanBuilder |
| | | import cn.sinata.xldutils.utils.myToast |
| | | import cn.sinata.xldutils.utils.showAllowingStateLoss |
| | | import cn.sinata.xldutils.utils.* |
| | | import cn.sinata.xldutils.utils.hideBankCard |
| | | import com.sinata.xqmuse.R |
| | | import com.sinata.xqmuse.dialog.MsgDialog |
| | | import com.sinata.xqmuse.network.HttpManager |
| | | import com.sinata.xqmuse.network.request |
| | | import com.sinata.xqmuse.ui.TransparentStatusBarActivity |
| | | import com.sinata.xqmuse.utils.Const |
| | | import kotlinx.android.synthetic.main.activity_input_code.* |
| | | import org.jetbrains.anko.startActivity |
| | | import java.util.* |
| | |
| | | private val timer by lazy { |
| | | object : CountDownTimer(60000, 1000) { |
| | | override fun onFinish() { |
| | | tv_3.text = "可重新获取短信验证码" |
| | | tv_3.text = "" |
| | | tv_get_code.isEnabled = true |
| | | tv_get_code.alpha = 1f |
| | | } |
| | |
| | | }) |
| | | msgDialog.showAllowingStateLoss(supportFragmentManager,"check") |
| | | }else{ |
| | | et_6.setText("") |
| | | tv_action.isEnabled = true |
| | | myToast("验证失败") |
| | | |
| | | val msgDialog = MsgDialog() |
| | | msgDialog.arguments = bundleOf("msg" to "手机号验证失败","title" to "验证失败") |
| | | msgDialog.showAllowingStateLoss(supportFragmentManager,"check") |
| | | } |
| | | }){_,_-> |
| | | tv_action.isEnabled = true |
| | |
| | | codeEts[cursorIndex].requestFocus() |
| | | } |
| | | } else { |
| | | code.deleteCharAt(code.lastIndex) |
| | | if (cursorIndex != 0) { //还没删到第一个 |
| | | cursorIndex-- |
| | | codeEts[cursorIndex].requestFocus() //焦点交给上一个 |
| | | // code.deleteCharAt(code.lastIndex) |
| | | // if (cursorIndex != 0) { //还没删到第一个 |
| | | // cursorIndex-- |
| | | // codeEts[cursorIndex].requestFocus() //焦点交给上一个 |
| | | // } |
| | | if (code.isNotEmpty()){ |
| | | cursorIndex = 0 |
| | | code.delete(0,code.length) |
| | | codeEts.forEach { |
| | | it.setText("") |
| | | } |
| | | et_1.requestFocus() |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { |
| | | } |
| | | }) |
| | | // it.setOnKeyListener { _, keyCode, event -> |
| | | // if (keyCode == KeyEvent.KEYCODE_DEL && event.action == KeyEvent.ACTION_UP) { |
| | | // if (cursorIndex != 0) { |
| | | // codeEts[cursorIndex - 1].setText("") |
| | | // } |
| | | // } |
| | | // false |
| | | // } |
| | | it.setOnFocusChangeListener { v, hasFocus -> |
| | | if (hasFocus){ |
| | | codeEts[cursorIndex].requestFocus() |
| | | val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager |
| | | imm.showSoftInput(codeEts[cursorIndex], InputMethodManager.SHOW_FORCED) |
| | | |
| | | it.setOnKeyListener { v, keyCode, event -> |
| | | if (keyCode == KeyEvent.KEYCODE_DEL&&it.text.isEmpty()&&cursorIndex!=0){ |
| | | code.delete(0,code.length) |
| | | cursorIndex = 0 |
| | | codeEts.forEach { |
| | | it.setText("") |
| | | } |
| | | et_1.requestFocus() |
| | | } |
| | | return@setOnKeyListener false |
| | | } |
| | | } |
| | | } |
| | | |
| | | override fun initView() { |
| | | tv_2.text = "验证码已发送至:${phone}" |
| | | if (!SPUtils.instance().getString(Const.User.TOKEN).isNullOrEmpty()) |
| | | title = "修改密码" |
| | | tv_2.text = "验证码已发送至:${phone.formatPhone()}" |
| | | tv_get_code.isEnabled = false |
| | | tv_get_code.alpha = 0.5f |
| | | timer.start() |
| | | } |
| | | et_1.postDelayed({ |
| | | try { |
| | | et_1.requestFocus() |
| | | (getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager) |
| | | .showSoftInput(et_1, InputMethodManager.SHOW_FORCED) |
| | | }catch (e:Exception){ |
| | | |
| | | } |
| | | } |
| | | },500) |
| | | } |
| | | } |