public Line rawInterpretedLine() {
   Line line = new Line(rawInterpretedValues);
   line.setHasLines(false);
   line.setPointRadius(1);
   line.setHasPoints(true);
   return line;
 }
 public Line inRangeValuesLine() {
   Line inRangeValuesLine = new Line(inRangeValues);
   inRangeValuesLine.setColor(Utils.COLOR_BLUE);
   inRangeValuesLine.setHasLines(false);
   inRangeValuesLine.setPointRadius(pointSize);
   inRangeValuesLine.setHasPoints(true);
   return inRangeValuesLine;
 }
 public Line highValuesLine() {
   Line highValuesLine = new Line(highValues);
   highValuesLine.setColor(Utils.COLOR_ORANGE);
   highValuesLine.setHasLines(false);
   highValuesLine.setPointRadius(pointSize);
   highValuesLine.setHasPoints(true);
   return highValuesLine;
 }
 public Line lowValuesLine() {
   Line lowValuesLine = new Line(lowValues);
   lowValuesLine.setColor(Color.parseColor("#C30909"));
   lowValuesLine.setHasLines(false);
   lowValuesLine.setPointRadius(pointSize);
   lowValuesLine.setHasPoints(true);
   return lowValuesLine;
 }
 public Line inRangeValuesLine() {
   Line inRangeValuesLine = new Line(inRangeValues);
   inRangeValuesLine.setColor(Color.parseColor("#00FF00"));
   inRangeValuesLine.setHasLines(false);
   inRangeValuesLine.setPointRadius(pointSize);
   inRangeValuesLine.setHasPoints(true);
   return inRangeValuesLine;
 }
 public Line highValuesLine() {
   Line highValuesLine = new Line(highValues);
   highValuesLine.setColor(Color.parseColor("#FFFF00"));
   highValuesLine.setHasLines(false);
   highValuesLine.setPointRadius(pointSize);
   highValuesLine.setHasPoints(true);
   return highValuesLine;
 }
 public Line minShowLine() {
   List<PointValue> minShowValues = new ArrayList<PointValue>();
   minShowValues.add(new PointValue((float) start_time, (float) defaultMinY));
   minShowValues.add(new PointValue((float) end_time, (float) defaultMinY));
   Line minShowLine = new Line(minShowValues);
   minShowLine.setHasPoints(false);
   minShowLine.setHasLines(false);
   return minShowLine;
 }
 public Line maxShowLine() {
   List<PointValue> maxShowValues = new ArrayList<PointValue>();
   maxShowValues.add(new PointValue((float) start_time / FUZZER, (float) defaultMaxY));
   maxShowValues.add(new PointValue((float) end_time / FUZZER, (float) defaultMaxY));
   Line maxShowLine = new Line(maxShowValues);
   maxShowLine.setHasLines(false);
   maxShowLine.setHasPoints(false);
   return maxShowLine;
 }
        @Override
        public void onDataReceived(DataReadResult dataReadResult) {
          Log.d(TAG, "Received activity result");
          final String DATE_FORMAT = "dd/MM";
          SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);

          List<Line> lines = new ArrayList<>(); // all lines
          List<PointValue> calories; // a single line
          calories = new ArrayList<>();
          int x_val = 0;
          List<AxisValue> xAxisValues = new ArrayList<>();

          if (dataReadResult.getBuckets().size() > 0) {
            for (Bucket bucket : dataReadResult.getBuckets()) {
              String date = dateFormat.format(bucket.getStartTime(TimeUnit.MILLISECONDS));
              DataSet dataSet = bucket.getDataSet(DataType.AGGREGATE_CALORIES_EXPENDED);
              Log.d(TAG, "New databucket with date: " + date);

              // Increase counter
              x_val = x_val + 1;

              // Set axis labels
              xAxisValues.add(new AxisValue(x_val).setLabel(date));

              // Add a zero measurement point
              calories.add(new PointValue(x_val, 0));

              List<DataPoint> dataPointList = dataSet.getDataPoints();
              for (DataPoint dp : dataPointList) {
                String timestamp = dateFormat.format(dp.getTimestamp(TimeUnit.MILLISECONDS));
                float calorie = dp.getValue(Field.FIELD_CALORIES).asFloat();

                // Set graph values
                calories.set(x_val - 1, new PointValue(x_val, calorie));
                Log.d(TAG, "timestamp: " + timestamp + ", calories: " + calorie);
              }
            }
            Line line = new Line(calories);
            line.setColor(ChartUtils.COLOR_BLUE);
            line.setHasLines(true);
            line.setHasPoints(false);
            line.setCubic(false);
            line.setHasLabels(false);
            line.setHasLabelsOnlyForSelected(true);
            lines.add(line);

            fitnessFragment.setCalorieData(xAxisValues, lines);
          }
        }
        @Override
        public void onDataReceived(DataReadResult dataReadResult) {
          Log.d(TAG, "Received activity result");
          final String DATE_FORMAT = "dd/MM";
          SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
          // GoogleApiSubscription.printData(dataReadResult);

          List<Line> lines = new ArrayList<>(); // all lines
          List<PointValue> walking = new ArrayList<>(); // a single line
          List<PointValue> biking = new ArrayList<>();
          List<PointValue> in_vehicle = new ArrayList<>();
          List<AxisValue> xAxisValues = new ArrayList<>();

          int x_val = 0;

          if (dataReadResult.getBuckets().size() > 0) {
            for (Bucket bucket : dataReadResult.getBuckets()) {
              String date = dateFormat.format(bucket.getStartTime(TimeUnit.MILLISECONDS));
              DataSet dataSet = bucket.getDataSet(DataType.AGGREGATE_ACTIVITY_SUMMARY);
              Log.d(TAG, "New databucket with date: " + date);

              // Increase counter
              x_val = x_val + 1;

              // Set axis labels
              xAxisValues.add(new AxisValue(x_val).setLabel(date));

              // Add a zero measurement point
              walking.add(new PointValue(x_val, 0));
              biking.add(new PointValue(x_val, 0));
              in_vehicle.add(new PointValue(x_val, 0));

              List<DataPoint> dataPointList = dataSet.getDataPoints();
              for (DataPoint dp : dataPointList) {
                String timestamp = dateFormat.format(dp.getTimestamp(TimeUnit.MILLISECONDS));
                String activity = dp.getValue(Field.FIELD_ACTIVITY).asActivity();
                int duration = dp.getValue(Field.FIELD_DURATION).asInt();

                if (dp.getValue(Field.FIELD_ACTIVITY).asActivity() == "walking") {
                  walking.set(x_val - 1, new PointValue(x_val, duration / 60000));
                } else if (dp.getValue(Field.FIELD_ACTIVITY).asActivity() == "biking") {
                  biking.set(x_val - 1, new PointValue(x_val, duration / 60000));
                } else if (dp.getValue(Field.FIELD_ACTIVITY).asActivity() == "in_vehicle") {
                  in_vehicle.set(x_val - 1, new PointValue(x_val, duration / 60000));
                }
                Log.d(
                    TAG,
                    "timestamp: "
                        + timestamp
                        + ", activity: "
                        + activity
                        + ", duration: "
                        + duration / 60000);
              }
            }
            Line line = new Line(walking);
            line.setColor(ChartUtils.COLOR_GREEN);
            line.setHasLines(true);
            line.setHasPoints(false);
            line.setCubic(false);
            lines.add(line);

            line = new Line(biking);
            line.setColor(ChartUtils.COLOR_BLUE);
            line.setHasLines(true);
            line.setHasPoints(false);
            line.setCubic(false);
            lines.add(line);

            line = new Line(in_vehicle);
            line.setColor(ChartUtils.COLOR_VIOLET);
            line.setHasLines(true);
            line.setHasPoints(false);
            line.setCubic(false);
            lines.add(line);

            fitnessFragment.setActivityData(xAxisValues, lines);
          }
        }