/** * Creates a new timer and starts it if start=true. * @param start if true, then start the timer; if false then don't start the timer. */ public MyTimer(boolean start){ timing = false; numTimers = 0; sumTime = 0; this.start(); }
class MyTimer extends CountDownTimer{ public MyTimer(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); } @Override public void onTick(long l) { } @Override public void onFinish() { viewPager.setCurrentItem(viewPager.getCurrentItem() + 1); myTimer.start(); } MyTimer myTimer = new MyTimer(1000*60, 1000); myTimer.start();
/** * Demo of usage * @param args command line args */ public static void main(String [] args){ MyTimer t = new MyTimer(); for(int i = 0; i < 10; i++){ t.start(); try{ Thread.sleep(1000); }catch (Exception e){ } t.stop(); } System.out.println("Time: " + t.getAvgTime()); }
DPrint.cl(debugID, "Num generated: " + (nGenerated) + " Unique: " + (hashedStates.size()) + " time: " + timer.getTime()); timer.start();