public void addTime(long time) { mTimerStart -= time; // inform listener about the time changed if (mListener != null) { mListener.onTimerTick(); if (mIsCountdownEnabled && getElapsedTime() >= mCountdown) { mListener.onCountdownFinish(); } } if (mIsTicking) { start(getElapsedTime()); } }
public void run() { // update time long elapsedTime = System.currentTimeMillis() - mTimerStart; // schedule event for next second mTimeHandler.postAtTime(this, SystemClock.uptimeMillis() + SECOND); // inform listener about the time changed if (mListener != null) { mListener.onTimerTick(); if (mIsCountdownEnabled && elapsedTime >= mCountdown) { mListener.onCountdownFinish(); } } }