Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix a formating bug in the display of times over an hour

  • Loading branch information...
commit 9fef81f2da012e7479ffc41f731543afebd63660 1 parent cccc258
techxplorer authored
View
2  res/values/strings.xml
@@ -251,7 +251,7 @@
<string name="misc_age_calculation_seconds">%d seconds</string>
<string name="misc_age_calculation_minutes">%d minutes</string>
- <string name="misc_age_calculation_hours">%d hours</string>
+ <string name="misc_age_calculation_hours">%.1f hours</string>
<string name="misc_age_calculation_more_than_a_day">more than a day</string>
<string name="misc_disance_metres">%s metres</string>
View
2  src/org/servalproject/maps/PoiInfoActivity.java
@@ -115,6 +115,8 @@ protected void onCreate(Bundle savedInstanceState) {
// calculate the distance between user and POI if possible
Location mLocation = LocationCollector.getLocation();
+ mView = (TextView) findViewById(R.id.poi_info_ui_txt_distance);
+
// calculate the distance
if(mLocation != null) {
View
32 src/org/servalproject/maps/utils/TimeUtils.java
@@ -67,28 +67,6 @@ public static String calculateAge(long time, String timeZone, Context context) {
long mTimeDifference = mCurrentTime - mToCalendar.getTimeInMillis();
return getMillisHumanReadable(mTimeDifference, context);
-
-// // convert the different into human readable representation
-// int mTime = (int) mTimeDifference / 60000;
-//
-// if(mTime < 1) {
-// // less than one minute
-// mTime = (int) (mTimeDifference % 60);
-// mReturn = String.format(context.getString(R.string.misc_age_calculation_seconds), mTime);
-// } else if(mTime > 60) {
-// // more than an hour
-// mTime = (int) (mTimeDifference / 3600);
-//
-// if(mTime > 24) { // more than 24 hours
-// mReturn = String.format(context.getString(R.string.misc_age_calculation_more_than_a_day), mTime);
-// } else {
-// mReturn = String.format(context.getString(R.string.misc_age_calculation_hours), mTime);
-// }
-// } else { // minutes
-// mReturn = String.format(context.getString(R.string.misc_age_calculation_minutes), mTime);
-// }
-//
-// return mReturn;
}
/**
@@ -197,12 +175,14 @@ public static String getMillisHumanReadable(long milliseconds, Context context)
mReturn = String.format(context.getString(R.string.misc_age_calculation_seconds), mTime);
} else if(mTime > 60) {
// more than an hour
- mTime = (int) (mTime / 3600);
+ // round the number of hours for display
+ double mHours = mTime / 60.0;
+ //mHours = (double)Math.round(mHours * 10) / 10;
- if(mTime > 24) { // more than 24 hours
- mReturn = String.format(context.getString(R.string.misc_age_calculation_more_than_a_day), mTime);
+ if(mHours > 24) { // more than 24 hours
+ mReturn = String.format(context.getString(R.string.misc_age_calculation_more_than_a_day), mHours);
} else {
- mReturn = String.format(context.getString(R.string.misc_age_calculation_hours), mTime);
+ mReturn = String.format(context.getString(R.string.misc_age_calculation_hours), mHours);
}
} else { // minutes
mReturn = String.format(context.getString(R.string.misc_age_calculation_minutes), mTime);
Please sign in to comment.
Something went wrong with that request. Please try again.