package com.cardinalsolutions.countdowntimer;
import android.app.Activity;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.text.format.Time;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.TextView;
import com.todddavies.components.progressbar.ProgressWheel;

/**
 * Countdown Timer
 *
 * CountdownTimerActivity is the main activity of this application.  To configure  is a utility class that allows the developer to turn off logging by setting the LOGGING
 * flag to false prior to generating an APK.
 *
 * @author Shane King
 *         28 Aug 2014
 *         10:00
 */
public class CountdownTimerActivity extends Activity {

	private static final String TAG = "CountdownTimer";

	private TextView mCountdownNote;
	private ProgressWheel mDaysWheel;
	private TextView mDaysLabel;
	private ProgressWheel mHoursWheel;
	private TextView mHoursLabel;
	private ProgressWheel mMinutesWheel;
	private TextView mMinutesLabel;
	private ProgressWheel mSecondsWheel;
	private TextView mSecondsLabel;

	// Timer setup
	Time conferenceTime = new Time(Time.getCurrentTimezone());
	int hour = 22;
	int minute = 33;
	int second = 0;
	int monthDay = 28;
	// month is zero based...7 == August
	int month = 7;
	int year = conferenceTime.year;

	// Values displayed by the timer
	private int mDisplayDays;
	private int mDisplayHours;
	private int mDisplayMinutes;
	private int mDisplaySeconds;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_countdown_timer);

		configureViews();
		configureConferenceDate();

	}

	private void configureViews() {

		this.mCountdownNote = (TextView) findViewById(R.id.activity_countdown_timer_note);
		this.mDaysWheel = (ProgressWheel) findViewById(R.id.activity_countdown_timer_days);
		this.mHoursWheel = (ProgressWheel) findViewById(R.id.activity_countdown_timer_hours);
		this.mMinutesWheel = (ProgressWheel) findViewById(R.id.activity_countdown_timer_minutes);
		this.mSecondsWheel = (ProgressWheel) findViewById(R.id.activity_countdown_timer_seconds);
		this.mDaysLabel = (TextView) findViewById(R.id.activity_countdown_timer_days_text);
		this.mHoursLabel = (TextView) findViewById(R.id.activity_countdown_timer_hours_text);
		this.mMinutesLabel = (TextView) findViewById(R.id.activity_countdown_timer_minutes_text);
		this.mSecondsLabel = (TextView) findViewById(R.id.activity_countdown_timer_seconds_text);

	}

	private void closeActivity() {
		// Start your subsequent activity here.  Increasing year so timer will never go away for
		// demo purposes only.  Remove next 2 lines of code in your app!!
		year = year + 1;
		configureConferenceDate();

	}

	private void configureConferenceDate() {
		conferenceTime.set(second, minute, hour, monthDay, month, year);
		conferenceTime.normalize(true);
		long confMillis = conferenceTime.toMillis(true);

		Time nowTime = new Time(Time.getCurrentTimezone());
		nowTime.setToNow();
		nowTime.normalize(true);
		long nowMillis = nowTime.toMillis(true);

		long milliDiff = confMillis - nowMillis;

		new CountDownTimer(milliDiff, 1000) {

			@Override
			public void onTick(long millisUntilFinished) {
				// decompose difference into days, hours, minutes and seconds
				CountdownTimerActivity.this.mDisplayDays = (int) ((millisUntilFinished / 1000) / 86400);
				CountdownTimerActivity.this.mDisplayHours = (int) (((millisUntilFinished / 1000) - (CountdownTimerActivity.this.mDisplayDays * 86400)) / 3600);
				CountdownTimerActivity.this.mDisplayMinutes = (int) (((millisUntilFinished / 1000) - ((CountdownTimerActivity.this.mDisplayDays * 86400) + (CountdownTimerActivity.this.mDisplayHours * 3600))) / 60);
				CountdownTimerActivity.this.mDisplaySeconds = (int) ((millisUntilFinished / 1000) % 60);

				CountdownTimerActivity.this.mDaysWheel.setText(String.valueOf(CountdownTimerActivity.this.mDisplayDays));
				CountdownTimerActivity.this.mDaysWheel.setProgress(CountdownTimerActivity.this.mDisplayDays);

				CountdownTimerActivity.this.mHoursWheel.setText(String.valueOf(CountdownTimerActivity.this.mDisplayHours));
				CountdownTimerActivity.this.mHoursWheel.setProgress(CountdownTimerActivity.this.mDisplayHours * 15);

				CountdownTimerActivity.this.mMinutesWheel.setText(String.valueOf(CountdownTimerActivity.this.mDisplayMinutes));
				CountdownTimerActivity.this.mMinutesWheel.setProgress(CountdownTimerActivity.this.mDisplayMinutes * 6);

				Animation an = new RotateAnimation(0.0f, 90.0f, 250f, 273f);
				an.setFillAfter(true);

				CountdownTimerActivity.this.mSecondsWheel.setText(String.valueOf(CountdownTimerActivity.this.mDisplaySeconds));
				CountdownTimerActivity.this.mSecondsWheel.setProgress(CountdownTimerActivity.this.mDisplaySeconds * 6);
			}

			@Override
			public void onFinish() {
				Logger.d(TAG, "Timer Finished...");
				// This is where you would launch the activity for 
				closeActivity();
			}
		}.start();
	}
}

@@ -1286,30 +1286,8 @@
 year
- = conferenceTime.year
 ;%0A%0A%09
@@ -1678,16 +1678,88 @@
 iews() %7B
+%0A%09%09%0A%09%09this.conferenceTime.setToNow();%0A%09%09this.year = conferenceTime.year;
 %0A%0A%09%09this
@@ -2562,252 +2562,8 @@
 %09%7D%0A%0A
-%09private void closeActivity() %7B%0A%09%09// Start your subsequent activity here.  Increasing year so timer will never go away for%0A%09%09// demo purposes only.  Remove next 2 lines of code in your app!!%0A%09%09year = year + 1;%0A%09%09configureConferenceDate();%0A%0A%09%7D%0A%0A
 %09pri
@@ -4716,78 +4716,123 @@
 %09%09%09%09
-// This is where you would launch the activity for %0A%09%09%09%09closeActivity(
+CountdownTimerActivity.this.mSecondsWheel.setText(%220%22);%0A%09%09%09%09CountdownTimerActivity.this.mSecondsWheel.setProgress(0
 );%0A%09

Update CountdownTimerActivity.java