onFinish()方法CountDownTimer太长? [英] onFinish() CountDownTimer method too long?

查看:2099
本文介绍了onFinish()方法CountDownTimer太长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:20/11/13:这是仍然没有得到解决。

Update: 20/11/13: This is still unresolved.

我想提出一个 CountDownTimer ,并在 onFinish()方法,我显然做的工作太多作为倒数第二和终点之间的延迟时间超过1秒(这是我的滴答之间的延迟)。

I am making a CountDownTimer and in the onFinish() method, I am apparently doing too much work as the delay between the last second and the finish takes longer than 1 second (which is my delay between ticks).

这是我的code。

mCountDownTimer = new CountDownTimer(GAME_LENGTH, 1000) {

public void onTick(long millisUntilFinished) {
                mCountDownTextView.setText("" + millisUntilFinished / 1000);
            }

            public void onFinish() {
                mCountDownTextView.setText("Game Over!");
                tl.setOnTouchListener(null);
                for (DotView dv : mAllDots) {
                    dv.setChangingColors(false, null, -1); // This is my own method
                }
                 }

现在的问题是:有没有执行在<$ C $的 onFinish()方法可能会长期运行的操作方式C> CountDownTimer 没有倒数第二和最后一跳之间的实际时间受到影响?

The question is: Is there a way to perform a potentially long running action in the onFinish() method of a CountDownTimer without the actual timings between the penultimate and last tick being affected?

推荐答案

我有同样的问题,我不认为这是在code中的 onFinish()这是造成这一点。

I had the same problem and I don't think it's the code in the onFinish() that's causing this.

我工作围绕这一问题进行动作时,(millisUntilFinished / 1000 == 1),而不是在 onFinish()

I worked around the problem performing the actions when (millisUntilFinished/1000 == 1) instead of in the onFinish().

我也用 mCountDownTextView.setText(将String.valueOf((millisUntilFinished / 1000) - 1))。由一个第二偏离的TextView

I also used mCountDownTextView.setText(String.valueOf((millisUntilFinished/1000) - 1)) to offset the textview by one second.

这篇关于onFinish()方法CountDownTimer太长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆