验证码bugfix

This commit is contained in:
oujunhui
2020-05-09 13:22:19 +08:00
parent 6a4ebdd2e0
commit e2c68edb9c
3 changed files with 19 additions and 9 deletions

View File

@@ -18,36 +18,37 @@ import com.yizhuan.erban.R;
public class CodeDownDescTimer extends CountDownTimer {
private TextView mTvSecond;
private TextView mTvDesc;
private TextView tvGetCode;
/**
* @param tv_second 秒数
* @param tv_desc 秒数后面的字
* @param tv_get_code 秒数后面的字
* @param millisInFuture The number of millis in the future from the call
* to {@link #start()} until the countdown is done and {@link #onFinish()}
* is called.
* @param countDownInterval The interval along the way to receiver
* {@link #onTick(long)} callbacks.
*/
public CodeDownDescTimer(TextView tv_second, TextView tv_desc, long millisInFuture, long countDownInterval) {
public CodeDownDescTimer(TextView tv_second, TextView tv_get_code, long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
this.mTvSecond = tv_second;
this.mTvDesc = tv_desc;
this.tvGetCode = tv_get_code;
}
@Override
public void onTick(long millisUntilFinished) {
mTvSecond.setVisibility(View.VISIBLE);
mTvSecond.setText(millisUntilFinished / 1000 + ""); //设置倒计时时间
mTvDesc.setClickable(false); //设置不可点击
mTvDesc.setText(Html.fromHtml("<font color=#F770FF font-size=10dp>s </font>" + "后可重新获取验证码"));
tvGetCode.setClickable(false); //设置不可点击
tvGetCode.setText(Html.fromHtml("<font color=#F770FF font-size=10dp>s </font>" + "后可重新获取验证码"));
}
@Override
public void onFinish() {
mTvSecond.setVisibility(View.GONE);
mTvDesc.setText(Html.fromHtml("<font color=#F770FF font-size=11dp>重新获取验证码</font>"));
mTvDesc.setClickable(true);//重新获得点击
tvGetCode.setText(Html.fromHtml("<font color=#F770FF font-size=11dp>重新获取验证码</font>"));
tvGetCode.setClickable(true);//重新获得点击
}
}

View File

@@ -120,6 +120,10 @@ public class LoginCodeActivity extends BaseLoginAct {
// startActivity(intent);
}
});
tvGetCode.setOnClickListener(v -> {
getSmsCode();
});
}
@Override

View File

@@ -66,10 +66,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/et_code"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="@dimen/dp_10"
>
<TextView
@@ -78,6 +78,9 @@
android:layout_height="wrap_content"
android:textColor="@color/color_F770FF"
android:visibility="gone"
tools:visibility="visible"
android:includeFontPadding="false"
android:text="60S"
android:textSize="@dimen/sp_15"
/>
@@ -86,8 +89,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/sp_11"
tools:text="重新获取验证码"
android:textColor="@color/white"
android:paddingBottom="@dimen/dp_10"
android:paddingTop="@dimen/dp_10"
/>