示例#1
0
  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());
    }
  }
示例#2
0
        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();
            }
          }
        }