Code cleanup: improve readability in TrackController

This commit is contained in:
Jimmy Shih
2013-06-14 09:57:01 -07:00
parent 001537863a
commit 33b4b62ad0
@@ -92,10 +92,11 @@ public class TrackController {
} }
isRecording = recording; isRecording = recording;
isPaused = paused; isPaused = paused;
containerView.setVisibility(alwaysShow || isRecording ? View.VISIBLE : View.GONE); boolean visible = alwaysShow || isRecording;
containerView.setVisibility(visible ? View.VISIBLE : View.GONE);
if (!alwaysShow && !isRecording) { if (!visible) {
stopTimer(); handler.removeCallbacks(updateTotalTimeRunnable);
return; return;
} }
@@ -109,12 +110,12 @@ public class TrackController {
statusTextView.setVisibility(isRecording ? View.VISIBLE : View.INVISIBLE); statusTextView.setVisibility(isRecording ? View.VISIBLE : View.INVISIBLE);
if (isRecording) { if (isRecording) {
statusTextView.setTextColor( statusTextView.setTextColor(activity.getResources()
activity.getResources().getColor(isPaused ? android.R.color.white : R.color.recording_text)); .getColor(isPaused ? android.R.color.white : R.color.recording_text));
statusTextView.setText(isPaused ? R.string.generic_paused : R.string.generic_recording); statusTextView.setText(isPaused ? R.string.generic_paused : R.string.generic_recording);
} }
stopTimer(); handler.removeCallbacks(updateTotalTimeRunnable);
totalTime = isRecording ? getTotalTime() : 0L; totalTime = isRecording ? getTotalTime() : 0L;
totalTimeTextView.setText(StringUtils.formatElapsedTimeWithHour(totalTime)); totalTimeTextView.setText(StringUtils.formatElapsedTimeWithHour(totalTime));
if (isRecording && !isPaused) { if (isRecording && !isPaused) {
@@ -130,7 +131,7 @@ public class TrackController {
public void onPause() { public void onPause() {
isResumed = false; isResumed = false;
stopTimer(); handler.removeCallbacks(updateTotalTimeRunnable);
} }
public void hide() { public void hide() {
@@ -141,13 +142,6 @@ public class TrackController {
containerView.setVisibility(View.VISIBLE); containerView.setVisibility(View.VISIBLE);
} }
/**
* Stops the timer.
*/
private void stopTimer() {
handler.removeCallbacks(updateTotalTimeRunnable);
}
/** /**
* Gets the total time for the current recording track. * Gets the total time for the current recording track.
*/ */