Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
WorkoutViewerActivity: Fix possible FCs before v8.0 release
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel <micrusa@hotmail.es>
  • Loading branch information
micrusa committed Sep 17, 2020
1 parent 24b5941 commit 5bad5cf
Showing 1 changed file with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void setupHrGraph(List<Integer> hr){

private void setupRepsGraph(List<Integer> reps, List<Integer> setsDuration){
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
if(reps.get(0) != 0){
if(reps.size() >= 1 && reps.get(0) != 0){
ArrayList<Entry> values = new ArrayList<>();
for(int i = 0; i < reps.size(); i++)
values.add(new Entry(i, reps.get(i)));
Expand All @@ -139,25 +139,29 @@ private void setupRepsGraph(List<Integer> reps, List<Integer> setsDuration){
dataSets.add(RepsLine);
}

ArrayList<Entry> workValues = new ArrayList<>();
ArrayList<Entry> restValues = new ArrayList<>();
for(int i = 0; i < setsDuration.size(); i++){
if(i % 2 == 0) //If it's a work set
workValues.add(new Entry((float) i / 2, setsDuration.get(i)));
else
restValues.add(new Entry((float) i / 2, setsDuration.get(i)));
if(setsDuration.size() >= 1){
ArrayList<Entry> workValues = new ArrayList<>();
ArrayList<Entry> restValues = new ArrayList<>();
for(int i = 0; i < setsDuration.size(); i++){
if(i % 2 == 0) //If it's a work set
workValues.add(new Entry((float) i / 2, setsDuration.get(i)));
else
restValues.add(new Entry((float) i / 2, setsDuration.get(i)));
}

LineDataSet WorkSetsDurationLine = new LineDataSet(workValues, getString(R.string.worktime));
setupLineDataSet(WorkSetsDurationLine, Color.RED);
dataSets.add(WorkSetsDurationLine);

LineDataSet RestSetsDurationLine = new LineDataSet(restValues, getString(R.string.resttime));
setupLineDataSet(RestSetsDurationLine, Color.GREEN);
dataSets.add(RestSetsDurationLine);
}

LineDataSet WorkSetsDurationLine = new LineDataSet(workValues, getString(R.string.worktime));
setupLineDataSet(WorkSetsDurationLine, Color.RED);
dataSets.add(WorkSetsDurationLine);

LineDataSet RestSetsDurationLine = new LineDataSet(restValues, getString(R.string.resttime));
setupLineDataSet(RestSetsDurationLine, Color.GREEN);
dataSets.add(RestSetsDurationLine);

repsGraph.setData(new LineData(dataSets));
setupGraph(repsGraph, true);
if(dataSets.size() >= 1) {
repsGraph.setData(new LineData(dataSets));
setupGraph(repsGraph, true);
}
}

private void setupGraph(LineChart graph, boolean enableX){
Expand Down

0 comments on commit 5bad5cf

Please sign in to comment.