1 package com.xtremelabs.robolectric.shadows; 2 3 import com.xtremelabs.robolectric.internal.Implementation; 4 import com.xtremelabs.robolectric.internal.Implements; 5 import com.xtremelabs.robolectric.internal.RealObject; 6 7 import android.os.CountDownTimer; 8 9 @Implements(CountDownTimer.class) 10 public class ShadowCountDownTimer { 11 12 private boolean started; 13 private long countDownInterval; 14 private long millisInFuture; 15 16 @RealObject CountDownTimer countDownTimer; 17 18 public void __constructor__(long millisInFuture, long countDownInterval) { 19 this.countDownInterval = countDownInterval; 20 this.millisInFuture = millisInFuture; 21 this.started = false; 22 } 23 24 @Implementation 25 public final synchronized CountDownTimer start() { 26 started = true; 27 return countDownTimer; 28 } 29 30 31 @Implementation 32 public final void cancel() { 33 started = false; 34 } 35 36 37 /** 38 * ****************************************************** 39 * Non-implementation methods for firing abstract methods 40 * ******************************************************* 41 */ 42 public void invokeTick(long millisUntilFinished) { 43 countDownTimer.onTick(millisUntilFinished); 44 } 45 46 public void invokeFinish() { 47 countDownTimer.onFinish(); 48 } 49 50 public boolean hasStarted() { 51 return started; 52 } 53 54 public long getCountDownInterval() { 55 return countDownInterval; 56 } 57 58 public long getMillisInFuture() { 59 return millisInFuture; 60 } 61 } 62