forked from upstream-mirrors/OpenTracks
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user