Skip to content

Commit

Permalink
Daydream: Fix non-updating graph
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Nov 2, 2016
1 parent 82d3a23 commit e0634a4
Showing 1 changed file with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public class XDripDreamService extends DreamService {
private TextView widgetDelta;
private TextView widgetStatusLine;
private TextView widgetReadingAge;
private ImageView graphimage;

private int graph_width;
private int graph_height;

private Bouncer mBouncer;
private Handler mainHandler;
Expand Down Expand Up @@ -81,10 +85,10 @@ public void onDreamingStarted() {
int screen_height = dm.heightPixels;

// TODO test on various screens

double screen_scale = (dm.densityDpi / 160f);
int graph_width = (int) (230 * screen_scale);
int graph_height = (int) (128 * screen_scale);
graph_width = (int) (230 * screen_scale);
graph_height = (int) (128 * screen_scale);
int widget_width = (int) (180 * screen_scale);
int widget_height = (int) (100 * screen_scale);
Log.d(TAG, "Width: " + graph_width + " Height: " + graph_height);
Expand All @@ -103,24 +107,9 @@ public void onDreamingStarted() {
mBouncer.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
mBouncer.setSpeed(0.1f);

long end = System.currentTimeMillis() + (60000 * 5);
long start = end - (60000 * 60 * 3) - (60000 * 10);
BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(this, start, end);
final Bitmap dreamBitmap = new BgSparklineBuilder(this)
.setBgGraphBuilder(bgGraphBuilder)
.setWidthPx(graph_width)
.setHeightPx(graph_height)
.showHighLine()
.showLowLine()
.setStart(System.currentTimeMillis() - 60000 * 60 * 3)
.showAxes(true)
.setBackgroundColor(getCol(ColorCache.X.color_notification_chart_background))
.setShowFiltered(DexCollectionType.hasFiltered() && Home.getPreferencesBooleanDefaultFalse("show_filtered_curve"))
.build();


final ImageView graphimage = new ImageView(this);
graphimage.setImageBitmap(dreamBitmap);
graphimage = new ImageView(this);
updateGraph();
// image.setBackgroundColor(0xFF004000);
mBouncer.addView(graphimage, gl);

Expand Down Expand Up @@ -183,10 +172,29 @@ private long updateData() {
final long timemod = ((300000 - dg.mssince) % 60000) + 10000;
Log.d(TAG, "Time mod: " + timemod);
if (timemod > 1000) delay = timemod;
updateGraph();
}
return delay; // default clock
}

private void updateGraph() {
long end = System.currentTimeMillis() + (60000 * 5);
long start = end - (60000 * 60 * 3) - (60000 * 10);
BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(this, start, end);
final Bitmap dreamBitmap = new BgSparklineBuilder(this)
.setBgGraphBuilder(bgGraphBuilder)
.setWidthPx(graph_width)
.setHeightPx(graph_height)
.showHighLine()
.showLowLine()
.setStart(System.currentTimeMillis() - 60000 * 60 * 3)
.showAxes(true)
.setBackgroundColor(getCol(ColorCache.X.color_notification_chart_background))
.setShowFiltered(DexCollectionType.hasFiltered() && Home.getPreferencesBooleanDefaultFalse("show_filtered_curve"))
.build();
graphimage.setImageBitmap(dreamBitmap);
}

// from http://code.google.com/p/android-daydream-samples
public class Bouncer extends FrameLayout implements TimeAnimator.TimeListener {
private float mMaxSpeed;
Expand Down

0 comments on commit e0634a4

Please sign in to comment.