Skip to content

Commit

Permalink
Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
krtkush committed Apr 27, 2017
1 parent 4d73cb8 commit 75ccdcc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ protected void onCreate(Bundle savedInstanceState) {
linearTimer = new LinearTimer.Builder()
.linearTimerView(linearTimerView)
.duration(duration)
.timerListener(this)
.progressDirection(LinearTimer.CLOCK_WISE_PROGRESSION)
.preFillAngle(0)
.endingAngle(360)
.getCountUpdate(LinearTimer.COUNT_UP_TIMER, 1000)
.build();

// Start the timer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ private void determinePreFillAngle() {
this.preFillAngle = (timeElapsedPercentage / 100) * 360;
}

/**
* Method to start the timer.
*/
public void startTimer() {

if (basicParametersCheck()) {
if (intStatusCode == LinearTimerStates.INITIALIZED.getStaus()) {
// Store the current status code in intStatusCode integer
intStatusCode = LinearTimerStates.ACTIVE.getStaus();
arcProgressAnimation = new ArcProgressAnimation(linearTimerView, endingAngle, this);
arcProgressAnimation.setDuration(animationDuration);
linearTimerView.startAnimation(arcProgressAnimation);

checkForCountUpdate();
} else
throw new IllegalStateException("LinearTimer is not in INITIALIZED state right now.");
}
}

/**
* A method to pause the running timer.
* @throws IllegalStateException IllegalStateException is thrown if the user tries to pause
Expand Down Expand Up @@ -167,25 +186,6 @@ else if(countType == COUNT_UP_TIMER)
}
}

/**
* Method to start the timer.
*/
public void startTimer() {

if (basicParametersCheck()) {
if (intStatusCode == LinearTimerStates.INITIALIZED.getStaus()) {
// Store the current status code in intStatusCode integer
intStatusCode = LinearTimerStates.ACTIVE.getStaus();
arcProgressAnimation = new ArcProgressAnimation(linearTimerView, endingAngle, this);
arcProgressAnimation.setDuration(animationDuration);
linearTimerView.startAnimation(arcProgressAnimation);

checkForCountUpdate();
} else
throw new IllegalStateException("LinearTimer is not in INITIALIZED state right now.");
}
}

/**
* Reset the timer to start angle and then start the progress again.
*/
Expand Down Expand Up @@ -351,23 +351,20 @@ private boolean listenerCheck() throws LinearTimerListenerMissingException {
*/
private void checkForCountUpdate() {

if (countType != -1) {
switch (countType) {

switch (countType) {
case COUNT_DOWN_TIMER:
countDownTimer = new
LinearTimerCountDownTimer(animationDuration,
updateInterval, timerListener);
countDownTimer.start();
break;

case COUNT_DOWN_TIMER:
countDownTimer = new
LinearTimerCountDownTimer(animationDuration,
updateInterval, timerListener);
countDownTimer.start();
break;

case COUNT_UP_TIMER:
countUpTimer = new LinearTimerCountUpTimer(animationDuration,
updateInterval, timerListener);
countUpTimer.start();
break;
}
case COUNT_UP_TIMER:
countUpTimer = new LinearTimerCountUpTimer(animationDuration,
updateInterval, timerListener);
countUpTimer.start();
break;
}
}

Expand Down

0 comments on commit 75ccdcc

Please sign in to comment.