Fix the display unit (metric or imperial) on ChartView both on

first app launch and when changing the display unit.

In ChartActivity, set the default to true to match the default
in ChartView.

When display unit changes, on the UI thread, request a layout so the
axises can be redrawn.
This commit is contained in:
Jimmy Shih
2011-12-21 10:55:07 -08:00
parent 6a9f3d9199
commit a17fc3efd2
@@ -77,7 +77,7 @@ public class ChartActivity extends Activity implements TrackDataListener {
private double trackMaxSpeed;
// Modes of operation
private boolean metricUnits;
private boolean metricUnits = true;
private boolean reportSpeed;
/*
@@ -452,14 +452,19 @@ public class ChartActivity extends Activity implements TrackDataListener {
@Override
public boolean onUnitsChanged(boolean metric) {
boolean changed = metric != this.metricUnits;
if (!changed) return false;
this.metricUnits = metric;
chartView.setMetricUnits(metric);
return true; // Reload data
if (this.metricUnits == metric) {
return false;
} else {
this.metricUnits = metric;
chartView.setMetricUnits(metric);
runOnUiThread(new Runnable() {
@Override
public void run() {
chartView.requestLayout();
}
});
return true;
}
}
@SuppressWarnings("hiding")