On ChartView, show either the speed or the pace label depending on the

user preference.
On StatsActivity, draw the unit label.
This commit is contained in:
Jimmy Shih
2011-12-21 13:27:51 -08:00
parent b0980e2e90
commit 828949efa4
2 changed files with 26 additions and 24 deletions
@@ -78,7 +78,7 @@ public class ChartActivity extends Activity implements TrackDataListener {
// Modes of operation // Modes of operation
private boolean metricUnits = true; private boolean metricUnits = true;
private boolean reportSpeed; private boolean reportSpeed = true;
/* /*
* UI elements: * UI elements:
@@ -466,16 +466,19 @@ public class ChartActivity extends Activity implements TrackDataListener {
return true; return true;
} }
@SuppressWarnings("hiding")
@Override @Override
public boolean onReportSpeedChanged(boolean reportSpeed) { public boolean onReportSpeedChanged(boolean speed) {
boolean changed = reportSpeed != this.reportSpeed; if (reportSpeed == speed) {
if (!changed) return false; return false;
}
this.reportSpeed = reportSpeed; reportSpeed = speed;
chartView.setReportSpeed(speed, this);
chartView.setReportSpeed(reportSpeed, this); runOnUiThread(new Runnable() {
@Override
return true; // Reload data public void run() {
chartView.requestLayout();
}
});
return true;
} }
} }
@@ -118,7 +118,8 @@ public class StatsActivity extends Activity implements TrackDataListener {
sv.setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_INSET); sv.setScrollBarStyle(ScrollView.SCROLLBARS_OUTSIDE_INSET);
showUnknownLocation(); showUnknownLocation();
updateLabels();
DisplayMetrics metrics = new DisplayMetrics(); DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics); getWindowManager().getDefaultDisplay().getMetrics(metrics);
if (metrics.heightPixels > 600) { if (metrics.heightPixels > 600) {
@@ -153,24 +154,22 @@ public class StatsActivity extends Activity implements TrackDataListener {
@Override @Override
public boolean onUnitsChanged(boolean metric) { public boolean onUnitsChanged(boolean metric) {
// Ignore if unchanged. if (utils.isMetricUnits() == metric) {
if (metric == utils.isMetricUnits()) return false; return false;
}
utils.setMetricUnits(metric); utils.setMetricUnits(metric);
updateLabels(); updateLabels();
return true;
return true; // Reload data
} }
@Override @Override
public boolean onReportSpeedChanged(boolean displaySpeed) { public boolean onReportSpeedChanged(boolean speed) {
// Ignore if unchanged. if (utils.isReportSpeed() == speed) {
if (displaySpeed == utils.isReportSpeed()) return false; return false;
}
utils.setReportSpeed(displaySpeed); utils.setReportSpeed(speed);
updateLabels(); updateLabels();
return true;
return true; // Reload data
} }
private void updateLabels() { private void updateLabels() {