diff options
Diffstat (limited to 'src/cgeo/geocaching/cgWaypoint.java')
| -rw-r--r-- | src/cgeo/geocaching/cgWaypoint.java | 161 |
1 files changed, 81 insertions, 80 deletions
diff --git a/src/cgeo/geocaching/cgWaypoint.java b/src/cgeo/geocaching/cgWaypoint.java index a11a2c5..c0dd719 100644 --- a/src/cgeo/geocaching/cgWaypoint.java +++ b/src/cgeo/geocaching/cgWaypoint.java @@ -1,96 +1,97 @@ package cgeo.geocaching; -import java.util.List; +import cgeo.geocaching.geopoint.Geopoint; import org.apache.commons.lang3.StringUtils; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.widget.TextView; -import cgeo.geocaching.geopoint.Geopoint; + +import java.util.List; public class cgWaypoint { public Integer id = 0; - public String geocode = "geocode"; - public String type = "waypoint"; - public String prefix = ""; - public String lookup = ""; - public String name = ""; - public String latlon = ""; - public String latitudeString = ""; - public String longitudeString = ""; - public Geopoint coords = null; - public String note = ""; + public String geocode = "geocode"; + public String type = "waypoint"; + public String prefix = ""; + public String lookup = ""; + public String name = ""; + public String latlon = ""; + public String latitudeString = ""; + public String longitudeString = ""; + public Geopoint coords = null; + public String note = ""; - public void setIcon(Resources res, cgBase base, TextView nameView) { - int iconId = R.drawable.waypoint_waypoint; - if (type != null) { - int specialId = res.getIdentifier("waypoint_" + type, "drawable", base.context.getPackageName()); - if (specialId > 0) { - iconId = specialId; - } - } - nameView.setCompoundDrawablesWithIntrinsicBounds((Drawable) res.getDrawable(iconId), null, null, null); - } + public void setIcon(Resources res, cgBase base, TextView nameView) { + int iconId = R.drawable.waypoint_waypoint; + if (type != null) { + int specialId = res.getIdentifier("waypoint_" + type, "drawable", base.context.getPackageName()); + if (specialId > 0) { + iconId = specialId; + } + } + nameView.setCompoundDrawablesWithIntrinsicBounds((Drawable) res.getDrawable(iconId), null, null, null); + } - public void merge(final cgWaypoint old) { - if (StringUtils.isBlank(prefix)) { - prefix = old.prefix; - } - if (StringUtils.isBlank(lookup)) { - lookup = old.lookup; - } - if (StringUtils.isBlank(name)) { - name = old.name; - } - if (StringUtils.isBlank(latlon)) { - latlon = old.latlon; - } - if (StringUtils.isBlank(latitudeString)) { - latitudeString = old.latitudeString; - } - if (StringUtils.isBlank(longitudeString)) { - longitudeString = old.longitudeString; - } - if (coords == null) { - coords = old.coords; - } - if (StringUtils.isBlank(note)) { - note = old.note; - } - if (note != null && old.note != null) { - if (old.note.length() > note.length()) { - note = old.note; - } - } - } + public void merge(final cgWaypoint old) { + if (StringUtils.isBlank(prefix)) { + prefix = old.prefix; + } + if (StringUtils.isBlank(lookup)) { + lookup = old.lookup; + } + if (StringUtils.isBlank(name)) { + name = old.name; + } + if (StringUtils.isBlank(latlon)) { + latlon = old.latlon; + } + if (StringUtils.isBlank(latitudeString)) { + latitudeString = old.latitudeString; + } + if (StringUtils.isBlank(longitudeString)) { + longitudeString = old.longitudeString; + } + if (coords == null) { + coords = old.coords; + } + if (StringUtils.isBlank(note)) { + note = old.note; + } + if (note != null && old.note != null) { + if (old.note.length() > note.length()) { + note = old.note; + } + } + } - public static void mergeWayPoints(List<cgWaypoint> newPoints, - List<cgWaypoint> oldPoints) { - // copy user modified details of the waypoints - if (newPoints != null && oldPoints != null) { - for (cgWaypoint old : oldPoints) { - boolean merged = false; - if (old != null && old.name != null && old.name.length() > 0) { - for (cgWaypoint waypoint : newPoints) { - if (waypoint != null && waypoint.name != null) { - if (old.name.equalsIgnoreCase(waypoint.name)) { - waypoint.merge(old); - merged = true; - break; - } - } - } - } - // user added waypoints should also be in the new list - if (!merged) { - newPoints.add(old); - } - } - } - } + public static void mergeWayPoints(List<cgWaypoint> newPoints, + List<cgWaypoint> oldPoints) { + // copy user modified details of the waypoints + if (newPoints != null && oldPoints != null) { + for (cgWaypoint old : oldPoints) { + boolean merged = false; + if (old != null && old.name != null && old.name.length() > 0) { + for (cgWaypoint waypoint : newPoints) { + if (waypoint != null && waypoint.name != null) { + if (old.name.equalsIgnoreCase(waypoint.name)) { + waypoint.merge(old); + merged = true; + break; + } + } + } + } + // user added waypoints should also be in the new list + if (!merged) { + newPoints.add(old); + } + } + } + } - public boolean isUserDefined() { - return type != null && type.equalsIgnoreCase("own"); - } + public boolean isUserDefined() { + return type != null && type.equalsIgnoreCase("own"); + } }
\ No newline at end of file |
