Skip to content

Commit

Permalink
Merge pull request #248 from hello/dz/graphs
Browse files Browse the repository at this point in the history
Changed graph look. [ref #107442248]
  • Loading branch information
zafrani committed Nov 20, 2015
2 parents 2c6cf2d + d99f465 commit a42ef36
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package is.hello.sense.ui.fragments;

import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
Expand Down Expand Up @@ -113,10 +112,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
this.graphPlaceholder = (TextView) view.findViewById(R.id.fragment_sensor_history_placeholder);
this.graphView = (GraphView) view.findViewById(R.id.fragment_sensor_history_graph);

graphView.setWantsFooters(false);
graphView.setGraphDrawable(new LineGraphDrawable(getResources()));
graphView.setAdapter(sensorDataSource);
graphView.setHeaderFooterProvider(sensorDataSource);
graphView.setHighlightListener(sensorDataSource);
graphView.setAdapter(sensorDataSource);
graphView.setTintColor(getResources().getColor(R.color.sensor_unknown));

this.historyModeSelector = (SelectorView) view.findViewById(R.id.fragment_sensor_history_mode);
Expand Down Expand Up @@ -249,7 +248,7 @@ public void onSelectionChanged(int newSelectionIndex) {
}


public class SensorDataSource extends SensorHistoryAdapter implements GraphView.HeaderFooterProvider, GraphView.HighlightListener {
public class SensorDataSource extends SensorHistoryAdapter implements GraphView.HighlightListener {
private boolean use24Time = false;

public void bindHistory(@NonNull ArrayList<SensorGraphSample> history) {
Expand Down Expand Up @@ -287,39 +286,6 @@ public void setUse24Time(boolean use24Time) {
notifyDataChanged();
}

@Override
public int getSectionHeaderFooterCount() {
return getSectionCount();
}

@ColorInt
@Override
public int getSectionHeaderTextColor(int section) {
return Color.TRANSPARENT;
}

@NonNull
@Override
public String getSectionHeader(int section) {
return "";
}

@ColorInt
@Override
public int getSectionFooterTextColor(int section) {
if (section == getSectionHeaderFooterCount() - 1) {
return Color.BLACK;
} else {
return Color.GRAY;
}
}

@NonNull
@Override
public String getSectionFooter(int section) {
return "";
}

//endregion


Expand Down
32 changes: 16 additions & 16 deletions app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,27 +186,27 @@ protected void onDraw(Canvas canvas) {
graphDrawable.draw(canvas);
}

final int headerHeight = calculateHeaderHeight(),
footerHeight = calculateFooterHeight();

if (wantsHeaders) {
height -= headerHeight;
minY += headerHeight;
} else {
final int topSpacing = (int) Math.ceil(markerPointHalf);
height -= topSpacing;
minY += topSpacing;
}

if (wantsFooters) {
height -= footerHeight;
}

if (headerFooterProvider != null) {
final int sectionCount = headerFooterProvider.getSectionHeaderFooterCount();
if (sectionCount > 0) {
final int headerHeight = calculateHeaderHeight(),
footerHeight = calculateFooterHeight();

final float sectionWidth = width / sectionCount;

if (wantsHeaders) {
height -= headerHeight;
minY += headerHeight;
} else {
final int topSpacing = (int) Math.ceil(markerPointHalf);
height -= topSpacing;
minY += topSpacing;
}

if (wantsFooters) {
height -= footerHeight;
}

for (int section = 0; section < sectionCount; section++) {
if (wantsHeaders) {
final int savedAlpha = headerTextPaint.getAlpha();
Expand Down

0 comments on commit a42ef36

Please sign in to comment.