• 短信计时器Utils


    package com.lvshandian.partylive.utils;

    import android.content.Context;
    import android.os.CountDownTimer;
    import android.widget.TextView;

    import com.lvshandian.partylive.R;

    public class TimeCount extends CountDownTimer {
    private TextView textView;
    private String data = "重新获取";
    private Context context;
    /**
    *
    * @param context 上下文
    * @param millisInFuture 总时长
    * @param countDownInterval 间隔时长
    * @param textView 显示的文字
    */

    public TimeCount(Context context, long millisInFuture, long countDownInterval,
    TextView textView) {
    super(millisInFuture, countDownInterval);// 参数依次为总时长,和计时的时间间隔
    this.textView = textView;
    this.context = context;
    }

    public TimeCount(long millisInFuture, long countDownInterval,
    TextView textView, String data) {
    super(millisInFuture, countDownInterval);// 参数依次为总时长,和计时的时间间隔
    this.textView = textView;
    this.data = data;
    }

    @Override
    public void onFinish() {// 计时完毕时触发
    textView.setText(data);
    textView.setClickable(true);
    textView.setTextColor(context.getResources().getColor(R.color.gray));
    textView.setBackgroundResource(R.drawable.yuanjiao_hui_bg);
    }

    @Override
    public void onTick(long millisUntilFinished) {// 计时过程显示
    textView.setClickable(false);
    textView.setText(millisUntilFinished / 1000 + "秒后重新获取");
    textView.setBackgroundResource(R.drawable.yuanjiao_hui_bg);
    textView.setTextColor(context.getResources().getColor(R.color.gray));
    }
    }

    使用:
    TimeCount time = new TimeCount(this, 60000, 1000, tvSendCode);
    time.start();



  • 相关阅读:
    pytest文档29-allure-pytest(最新最全,保证能搞成功!)
    使用 JMeter 进行压力测试
    web自动化针对PO模式进行二次封装之basepage
    关于面试总结-http协议相关面试题 -----转载
    移动APP测试基础分享
    基于python+requests+unittest框架接口自动化测试设计开发
    jmeter断言接口响应字段大小
    csv文件转换为xlsx文件
    钉钉机器人发群消息笔记
    docker学习笔记
  • 原文地址:https://www.cnblogs.com/huihuizhang/p/6605899.html
Copyright © 2020-2023  润新知