Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workout zero repeat crash #625

Merged
merged 1 commit into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/src/org/runnerup/view/RunActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ private View getWorkoutRow(org.runnerup.workout.Step step, int level, View conve
durationValue.setText("");
}
if (currentStep == step) {
view.setBackgroundResource(android.R.color.background_light);
//view.setBackgroundResource(android.R.color.background_light);
} else {
view.setBackgroundResource(android.R.color.black);
}
Expand All @@ -538,9 +538,8 @@ private View getWorkoutRow(org.runnerup.workout.Step step, int level, View conve
formatter.format(Formatter.Format.TXT_SHORT, step.getTargetType(), maxValue));
}
}

if (step.getRepeatCount() > 0) {
if (step.getCurrentRepeat() == step.getRepeatCount()) {
if (step.getIntensity() == Intensity.REPEAT){
if (step.getCurrentRepeat() >= step.getRepeatCount()) {
durationValue.setText(getString(R.string.Finished));
} else {
durationValue.setText("" + (step.getCurrentRepeat() + 1) + "/"
Expand Down
15 changes: 6 additions & 9 deletions app/src/org/runnerup/workout/RepeatStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@TargetApi(Build.VERSION_CODES.FROYO)
public class RepeatStep extends Step {

int repeatCount = 1;
int repeatCount = 0;

public ArrayList<Step> getSteps() {
return steps;
Expand Down Expand Up @@ -105,20 +105,17 @@ public void onPause(Workout s) {

@Override
public boolean onTick(Workout w) {
if (steps.get(currentStep).onTick(w)) {
return true;
}
return false;
return currentRepeat >= repeatCount || steps.get(currentStep).onTick(w);
}

@Override
public boolean onNextStep(Workout w) {
if (steps.get(currentStep).onNextStep(w)) {
currentStep++;
if (currentStep == steps.size()) {
if (currentStep >= steps.size()) {
currentStep = 0;
currentRepeat++;
if (currentRepeat == repeatCount) {
if (currentRepeat >= repeatCount) {
return true;
}
for (Step s : steps) {
Expand Down Expand Up @@ -188,10 +185,10 @@ public Step getCurrentStep() {

@Override
public boolean isLastStep() {
if (currentRepeat >= repeatCount)
return true;
if (currentStep + 1 < steps.size())
return false;
if (currentRepeat < repeatCount)
return false;
return steps.get(currentStep).isLastStep();
}

Expand Down
15 changes: 8 additions & 7 deletions app/src/org/runnerup/workout/Workout.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public double getDistance(Scope scope) {
case LAP:
if (currentStep != null)
return currentStep.getDistance(this, scope);
if (BuildConfig.DEBUG) { throw new AssertionError(); }
//if (BuildConfig.DEBUG) { throw new AssertionError(); }
break;
case CURRENT:
break;
Expand All @@ -326,7 +326,7 @@ public double getTime(Scope scope) {
case LAP:
if (currentStep != null)
return currentStep.getTime(this, scope);
if (BuildConfig.DEBUG) { throw new AssertionError(); }
//if (BuildConfig.DEBUG) { throw new AssertionError(); }
break;
case CURRENT:
return System.currentTimeMillis() / 1000; // now
Expand Down Expand Up @@ -442,6 +442,7 @@ public double getCadence(Scope scope) {
double t = getTime(scope); // in seconds
double b = -1; //TODO get steps for scope

//TODO
if (BuildConfig.DEBUG) { throw new AssertionError(); }
if (t != 0) {
return (60 * b)/ 2 / t; // bpm
Expand Down Expand Up @@ -501,8 +502,8 @@ public int getSport() {

@Override
public Intensity getIntensity() {
if (currentStep == null)
return Intensity.ACTIVE; // needed ??
if (currentStep == null || currentStep.getCurrentStep() == null)
return Intensity.ACTIVE; //No next step, assertion

return currentStep.getCurrentStep().getIntensity();
}
Expand Down Expand Up @@ -553,9 +554,9 @@ void saveLap(ContentValues tmp, boolean next) {
}
}

public int getStepCount() {
return steps.size();
}
//public int getStepCount() {
// return steps.size();
//}

public boolean isLastStep() {
if (currentStepNo + 1 < steps.size())
Expand Down