Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have solved my problem. Just check the previous delay, below is the solution.</p> <pre><code>private Long mPeriod = Long.parseLong("8000"); public void startTimer() { Logger.i("startTimer", "startTimer"); stopTimer(); mTimer = new Timer(); mTimerTask = new TimerTask() { @Override public void run() { // postInvalidate(); Logger.i("timer", "timer"); Thread th = new Thread(new Runnable() { @Override public void run() { Logger.i("thread", "thread"); Long ll = System.currentTimeMillis(); mRelativeTime = DateUtils.getRelativeTimeSpanString( Long.parseLong(mText + ""), ll, 0); Long diff = ll - Long.parseLong(mText + ""); // long diffSeconds = diff / 1000 % 60; long diffMinutes = diff / (60 * 1000) % 60; long diffHours = diff / (60 * 60 * 1000) % 60; Logger.d("diffMinutes", diffMinutes + ""); Logger.d("diffHours", diffHours + ""); if (diffMinutes == 0 &amp;&amp; diffHours == 0 &amp;&amp; mTimerTask != 5000) { Logger.i("5000", "5000"); mPeriod = Long.parseLong("5000"); startTimer(); } else if (diffMinutes &lt; 60 &amp;&amp; diffMinutes != 0 &amp;&amp; diffHours == 0 &amp;&amp; mTimerTask != 30000) { Logger.i("30000", "30000"); mPeriod = Long.parseLong("30000"); startTimer(); } else if (diffHours &gt; 0 &amp;&amp; mTimerTask != 600000) { Logger.i("600000", "600000"); mPeriod = Long.parseLong("600000"); startTimer(); } // Change text handler.sendEmptyMessage(0); } }); th.run(); } }; mTimer.scheduleAtFixedRate(mTimerTask, 0, mPeriod); } public void stopTimer() { if (mTimer != null) { mTimer.cancel(); mTimer = null; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload