From 0278c7388f4184a7fc3aca3ab8e50fefc14ff733 Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Fri, 25 Jan 2019 09:35:52 +0200 Subject: [PATCH] Added default units of measurement if not specified in the object #6383 - added new category and some refactoring --- .../builders/AmenityMenuBuilder.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index b7aeea9f5a..630baa42ac 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -689,6 +689,7 @@ public class AmenityMenuBuilder extends MenuBuilder { switch (key){ case "width": case "height": + case "seamark_height": case "depth": if (metricSystem == OsmandSettings.MetricsConstants.MILES_AND_FEET) { units = mapActivity.getResources().getString(R.string.foot); @@ -699,6 +700,7 @@ public class AmenityMenuBuilder extends MenuBuilder { } else { units = mapActivity.getResources().getString(R.string.m); } + prefix = prefixConstructor(prefix, units); break; case "distance": value = String.valueOf(OsmAndFormatter @@ -712,28 +714,33 @@ public class AmenityMenuBuilder extends MenuBuilder { } else { units = mapActivity.getResources().getString(R.string.km); } + prefix = prefixConstructor(prefix, units); break; case "capacity": units = mapActivity.getResources().getString(R.string.cubic_m); + prefix = prefixConstructor(prefix, units); break; case "maxweight": units = mapActivity.getResources().getString(R.string.cubic_m); + prefix = prefixConstructor(prefix, units); break; case "students": case "spots": case "seats": units = "capacity"; + prefix = prefixConstructor(prefix, units); + break; } - if (!prefix.isEmpty()) { - prefix = prefix + ", " + units; - } else { - prefix = units; - } return new String[]{prefix, value}; } + private String prefixConstructor(String prefix, String units){ + return (!prefix.isEmpty()) ? (prefix + ", " + units) : units; + + } + public void buildAmenityRow(View view, AmenityInfoRow info) { if (info.icon != null) { buildRow(view, info.icon, info.text, info.textPrefix, info.collapsable, info.collapsableView,