From d4ac53b9238da83cbf1fc45dde56df6b0b46cb97 Mon Sep 17 00:00:00 2001 From: ricky barrette Date: Sun, 1 Aug 2010 16:22:14 +0000 Subject: [PATCH] in SweetSounds.java, CountDownTimer.class, onTick() i added hours to the output. i also renamed the method padSeconds() to padTime() also in TimePickerPreference.java i added the call layout.removeAllViewes() in onCreateView() --- .../android/SweetSoundsLite/SweetSounds.java | 20 ++++++++++--------- .../SweetSoundsLite/TimePickerPreference.java | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/SweetDreamsLite/src/com/TwentyCodes/android/SweetSoundsLite/SweetSounds.java b/SweetDreamsLite/src/com/TwentyCodes/android/SweetSoundsLite/SweetSounds.java index 8a5901e..a050276 100644 --- a/SweetDreamsLite/src/com/TwentyCodes/android/SweetSoundsLite/SweetSounds.java +++ b/SweetDreamsLite/src/com/TwentyCodes/android/SweetSoundsLite/SweetSounds.java @@ -343,8 +343,6 @@ public class SweetSounds extends Activity implements OnClickListener, OnSeekBarC * @author ricky barrette */ class Timer extends CountDownTimer { - int minutes; - int seconds; /** * creates a new count down timer that stops play back of a sound track after specified time, and @@ -356,10 +354,12 @@ public class SweetSounds extends Activity implements OnClickListener, OnSeekBarC Log.i(TAG,"Timer()"); Log.v(TAG,"millisInFuture = "+ millisInFuture); timeLeft = (TextView) findViewById(R.id.time_left); - minutes = (int) (millisInFuture / 60000); - seconds = (int) (millisInFuture % 60000); + int hours = (int) (millisInFuture / 3600000); + millisInFuture = millisInFuture - (hours * 3600000); + int minutes = (int) ( millisInFuture / 60000); + int seconds = (int) (millisInFuture % 60000); seconds = seconds / 1000; - timeLeft.setText(minutes +" : "+ padSeconds(seconds)); + timeLeft.setText(hours +" : "+ padTime(minutes) +" : "+ padTime(seconds)); } /** @@ -389,10 +389,12 @@ public class SweetSounds extends Activity implements OnClickListener, OnSeekBarC @Override public void onTick(long millisUntilFinished) { Log.i(TAG,"onTick()"); - minutes = (int) (millisUntilFinished / 60000); - seconds = (int) (millisUntilFinished % 60000); + int hours = (int) (millisUntilFinished / 3600000); + millisUntilFinished = millisUntilFinished - (hours * 3600000); + int minutes = (int) ( millisUntilFinished / 60000); + int seconds = (int) (millisUntilFinished % 60000); seconds = seconds / 1000; - timeLeft.setText(minutes +" : "+ padSeconds(seconds)); + timeLeft.setText(hours +" : "+ padTime(minutes) +" : "+ padTime(seconds)); } /** @@ -401,7 +403,7 @@ public class SweetSounds extends Activity implements OnClickListener, OnSeekBarC * @return formated string * @author ricky barrette */ - private String padSeconds(int seconds){ + private String padTime(int seconds){ if (seconds <= 9) return "0"+ seconds; return ""+ seconds; diff --git a/SweetDreamsLite/src/com/TwentyCodes/android/SweetSoundsLite/TimePickerPreference.java b/SweetDreamsLite/src/com/TwentyCodes/android/SweetSoundsLite/TimePickerPreference.java index 5dea6eb..47c1128 100644 --- a/SweetDreamsLite/src/com/TwentyCodes/android/SweetSoundsLite/TimePickerPreference.java +++ b/SweetDreamsLite/src/com/TwentyCodes/android/SweetSoundsLite/TimePickerPreference.java @@ -102,6 +102,8 @@ public class TimePickerPreference extends Preference implements OnTimeChangedLis layout.setPadding(15, 5, 10, 5); layout.setOrientation(LinearLayout.VERTICAL); + layout.removeAllViews(); + /* * create a textview that will be used to display the title provided in xml * and add it to the lay out