Fix metrics fix

This commit is contained in:
Victor Shcherb 2012-09-07 15:08:36 +02:00
parent b4734ca136
commit f411eaf2dd
3 changed files with 14 additions and 6 deletions

View file

@ -104,15 +104,23 @@ public class OsmAndFormatter {
if (kmh >= 15 || (am == ApplicationMode.CAR)) { if (kmh >= 15 || (am == ApplicationMode.CAR)) {
return ((int) kmh) + " " + ctx.getString(R.string.km_h); return ((int) kmh) + " " + ctx.getString(R.string.km_h);
} }
kmh = ((int) kmh * 10f) / 10f; int kmh10 = (int) (kmh * 10f);
return kmh + " " + ctx.getString(R.string.km_h); if (kmh10 % 10 == 0) {
return (kmh10 / 10) + " " + ctx.getString(R.string.km_h);
} else {
return (kmh10 / 10f) + " " + ctx.getString(R.string.km_h);
}
} else { } else {
float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE; float mph = kmh * METERS_IN_KILOMETER / METERS_IN_ONE_MILE;
if (mph >= 10) { if (mph >= 10) {
return ((int) (mph)) + " " + ctx.getString(R.string.mile_per_hour); return ((int) (mph)) + " " + ctx.getString(R.string.mile_per_hour);
} else { } else {
mph = ((int) mph * 10f) / 10f; int mph10 = (int) (mph * 10f);
return mph + " " + ctx.getString(R.string.mile_per_hour); if(mph10 % 10 == 0) {
return (mph10 / 10) + " " + ctx.getString(R.string.mile_per_hour);
} else {
return (mph10 / 10f) + " " + ctx.getString(R.string.mile_per_hour);
}
} }
} }
} }

View file

@ -409,7 +409,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
* @return * @return
*/ */
private boolean distChanged(int oldDist, int dist){ private boolean distChanged(int oldDist, int dist){
if(oldDist != 0 && oldDist - dist < 30){ if(oldDist != 0 && Math.abs(oldDist - dist) > 30){
return false; return false;
} }
return true; return true;

View file

@ -603,7 +603,7 @@ public class RouteInfoControls {
public boolean distChanged(int oldDist, int dist){ public boolean distChanged(int oldDist, int dist){
if(oldDist != 0 && oldDist - dist < 10){ if(oldDist != 0 && Math.abs(oldDist - dist) > 10){
return false; return false;
} }
return true; return true;