@@ -0,0 +1,3138 @@
+package com.brucemax.boxintervals;%0A%0Aimport android.os.Handler;%0Aimport android.os.Message;%0Aimport android.os.SystemClock;%0A%0Apublic abstract class CountDownTimerWithPause %7B%0A%0A    private long mMillisInFuture;%0A    private long mCountdownInterval;%0A    private long mStopTimeInFuture;%0A    private long mValuePause;%0A    private boolean timerIsFinish = true;%0A%0A    public CountDownTimerWithPause(long millisInFuture, long countDownInterval) %7B%0A        mMillisInFuture = millisInFuture;%0A        mCountdownInterval = countDownInterval;%0A    %7D%0A%0A    public void setMillisInFuture(long millisInFuture) %7B%0A        this.mMillisInFuture = millisInFuture;%0A    %7D%0A%0A    public void setCountdownInterval(long countdownInterval) %7B%0A        this.mCountdownInterval = countdownInterval;%0A    %7D%0A    %0A%09public synchronized final void pause() %7B%0A%09%09if(!mHandler.hasMessages(MSG)) return;%0A%09%09mValuePause = mStopTimeInFuture - SystemClock.elapsedRealtime();%0A%09%09mHandler.removeMessages(MSG);%0A%09%7D%0A%0A%09public synchronized final void resume() %7B%0A%09%09if(mHandler.hasMessages(MSG)) return;%0A%09%09if(timerIsFinish) return;%0A%09%09mStopTimeInFuture = SystemClock.elapsedRealtime() + mValuePause;%0A%09%09mHandler.sendMessage(mHandler.obtainMessage(MSG));%0A%09%7D%0A%09%0A%09public synchronized final boolean isActive() %7B%0A%09%09if (mHandler.hasMessages(MSG))%0A%09%09%09return true;%0A%09%09return false;%0A%09%7D%0A%0A    public final void cancel() %7B%0A        mHandler.removeMessages(MSG);%0A    %7D%0A%0A    public synchronized final CountDownTimerWithPause start() %7B%0A        if (mMillisInFuture %3C= 0) %7B%0A            onFinish();%0A            timerIsFinish = true;%0A            return this;%0A        %7D%0A        mStopTimeInFuture = SystemClock.elapsedRealtime() + mMillisInFuture;%0A        mHandler.sendMessage(mHandler.obtainMessage(MSG));%0A        timerIsFinish = false;%0A        return this;%0A    %7D%0A%0A    public abstract void onTick(long millisUntilFinished);%0A    public abstract void onFinish();%0A    private static final int MSG = 1;%0A%0A    // handles counting down%0A    private Handler mHandler = new Handler() %7B%0A%0A        @Override%0A        public void handleMessage(Message msg) %7B%0A%0A            synchronized (CountDownTimerWithPause.this) %7B%0A                final long millisLeft = mStopTimeInFuture - SystemClock.elapsedRealtime();%0A%0A                if (millisLeft %3C= 0) %7B%0A                %09timerIsFinish = true;%0A                    onFinish();%0A                %7D else if (millisLeft %3C mCountdownInterval) %7B%0A                    // no tick, just delay until done%0A                    sendMessageDelayed(obtainMessage(MSG), millisLeft);%0A                %7D else %7B%0A                    long lastTickStart = SystemClock.elapsedRealtime();%0A                    onTick(millisLeft);%0A%0A                    // take into account user's onTick taking time to execute%0A                    long delay = lastTickStart + mCountdownInterval - SystemClock.elapsedRealtime();%0A%0A                    // special case: user's onTick took more than interval to%0A                    // complete, skip to next interval%0A                    while (delay %3C 0) delay += mCountdownInterval;%0A%0A                    sendMessageDelayed(obtainMessage(MSG), delay); %0A                %7D%0A            %7D%0A        %7D%0A    %7D;%0A%7D

add file with timer