我的倒数计时器运作不正常

时间:2019-02-08 13:43:55

标签: android countdowntimer

我有一个倒计时计时器,每隔X秒就会执行一次操作。 当秒数很少时,假设6 ..可以正常工作,但是当秒数很多时,例如240,它会打印出这样的日志:

2019-02-08 16:40:18.160 23195-23195/com.pondhoppers.riptide.app I/System.out:  waiting time left - 47
2019-02-08 16:40:18.181 23195-23195/com.pondhoppers.riptide.app I/System.out: waiting time left - 41
2019-02-08 16:40:18.208 23195-23195/com.pondhoppers.riptide.app I/System.out: waiting time left - 35
2019-02-08 16:40:18.233 23195-23195/com.pondhoppers.riptide.app I/System.out: waiting time left - 29
2019-02-08 16:40:18.298 23195-23195/com.pondhoppers.riptide.app I/System.out: waiting time left - 23
2019-02-08 16:40:18.323 23195-23195/com.pondhoppers.riptide.app I/System.out: waiting time left - 3

代码:

new CountDownTimer(240000, 1000) {
    @Override
    public final void onTick(final long millisUntilFinished) {
        System.out.println("waiting time left - " + (int) (millisUntilFinished * .001f));
        tvRaffleCount.setText(String.valueOf((Integer.valueOf(countDown)-1000)* 60000));
    }

    @Override
    public final void onFinish() {
        try {
            tvRaffleCount.setText("");
        } catch (Exception v) {
            //raffle mode is off
            v.printStackTrace();
        }

    }
}.start();

0 个答案:

没有答案