aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2011-12-03 15:12:03 +0100
committerBananeweizen <bananeweizen@gmx.de>2011-12-03 15:12:03 +0100
commitda83fd577df3f69027040a18573a0fb1e2111f40 (patch)
tree9bc2ce5de5913baa2630b9b09f4e6d71a236d2c7 /main/src
parent0c22235950d17dcae886424810eafd67a40c3ad4 (diff)
downloadcgeo-da83fd577df3f69027040a18573a0fb1e2111f40.zip
cgeo-da83fd577df3f69027040a18573a0fb1e2111f40.tar.gz
cgeo-da83fd577df3f69027040a18573a0fb1e2111f40.tar.bz2
refactoring: reduce boxing/unboxing craziness
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/CacheDetailActivity.java12
-rw-r--r--main/src/cgeo/geocaching/IBasicCache.java4
-rw-r--r--main/src/cgeo/geocaching/IWaypoint.java2
-rw-r--r--main/src/cgeo/geocaching/apps/AbstractLocusApp.java4
-rw-r--r--main/src/cgeo/geocaching/cgBase.java48
-rw-r--r--main/src/cgeo/geocaching/cgCache.java40
-rw-r--r--main/src/cgeo/geocaching/cgCacheListAdapter.java20
-rw-r--r--main/src/cgeo/geocaching/cgCoord.java18
-rw-r--r--main/src/cgeo/geocaching/cgData.java6
-rw-r--r--main/src/cgeo/geocaching/cgGeo.java2
-rw-r--r--main/src/cgeo/geocaching/cgWaypoint.java17
-rw-r--r--main/src/cgeo/geocaching/cgeo.java2
-rw-r--r--main/src/cgeo/geocaching/cgeoaddresses.java8
-rw-r--r--main/src/cgeo/geocaching/cgeoapplication.java14
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java16
-rw-r--r--main/src/cgeo/geocaching/cgeocoords.java8
-rw-r--r--main/src/cgeo/geocaching/cgeonavigate.java2
-rw-r--r--main/src/cgeo/geocaching/cgeopopup.java2
-rw-r--r--main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java5
-rw-r--r--main/src/cgeo/geocaching/files/GPXParser.java8
-rw-r--r--main/src/cgeo/geocaching/files/LocParser.java4
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java2
-rw-r--r--main/src/cgeo/geocaching/maps/CachesOverlay.java2
-rw-r--r--main/src/cgeo/geocaching/sorting/DifficultyComparator.java2
-rw-r--r--main/src/cgeo/geocaching/sorting/FindsComparator.java2
-rw-r--r--main/src/cgeo/geocaching/sorting/TerrainComparator.java2
26 files changed, 124 insertions, 128 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java
index 0b80265..cb77136 100644
--- a/main/src/cgeo/geocaching/CacheDetailActivity.java
+++ b/main/src/cgeo/geocaching/CacheDetailActivity.java
@@ -610,7 +610,7 @@ public class CacheDetailActivity extends AbstractActivity {
if (cache != null && cache.getElevation() != null) {
if (geo.altitudeNow != null) {
- Double diff = (cache.getElevation() - geo.altitudeNow);
+ double diff = (cache.getElevation() - geo.altitudeNow);
if (diff >= 0) {
dist.append(" ↗");
} else if (diff < 0) {
@@ -701,7 +701,7 @@ public class CacheDetailActivity extends AbstractActivity {
do {
calIdPre = cursor.getString(calIdIn);
if (calIdPre != null) {
- calId = new Integer(calIdPre);
+ calId = Integer.parseInt(calIdPre);
}
calName = cursor.getString(calNameIn);
@@ -1124,12 +1124,12 @@ public class CacheDetailActivity extends AbstractActivity {
cacheDistanceView = addCacheDetail(R.string.cache_distance, cache.getDistance() != null ? "~" + cgBase.getHumanDistance(cache.getDistance()) : "--");
// difficulty
- if (cache.getDifficulty() != null && cache.getDifficulty() > 0) {
+ if (cache.getDifficulty() > 0) {
addStarRating(R.string.cache_difficulty, cache.getDifficulty());
}
// terrain
- if (cache.getTerrain() != null && cache.getTerrain() > 0) {
+ if (cache.getTerrain() > 0) {
addStarRating(R.string.cache_terrain, cache.getTerrain());
}
@@ -1527,7 +1527,7 @@ public class CacheDetailActivity extends AbstractActivity {
final Button offlineStore = (Button) view.findViewById(R.id.offline_store);
if (cache.getReason() >= 1) {
- Long diff = (System.currentTimeMillis() / (60 * 1000)) - (cache.getDetailedUpdate() / (60 * 1000)); // minutes
+ long diff = (System.currentTimeMillis() / (60 * 1000)) - (cache.getDetailedUpdate() / (60 * 1000)); // minutes
String ago = "";
if (diff < 15) {
@@ -1959,7 +1959,7 @@ public class CacheDetailActivity extends AbstractActivity {
private class LogInflaterTask extends AsyncTask<Void, Void, Void> {
private List<RelativeLayout> loglist = new LinkedList<RelativeLayout>();
private String logCounter;
- private Boolean showLogCounter = false;
+ private boolean showLogCounter = false;
@Override
protected Void doInBackground(Void... params) {
diff --git a/main/src/cgeo/geocaching/IBasicCache.java b/main/src/cgeo/geocaching/IBasicCache.java
index f087bfb..5e67b2d 100644
--- a/main/src/cgeo/geocaching/IBasicCache.java
+++ b/main/src/cgeo/geocaching/IBasicCache.java
@@ -39,12 +39,12 @@ public interface IBasicCache extends ILogable {
/**
* @return Difficulty assessment
*/
- public abstract Float getDifficulty();
+ public abstract float getDifficulty();
/**
* @return Terrain assessment
*/
- public abstract Float getTerrain();
+ public abstract float getTerrain();
diff --git a/main/src/cgeo/geocaching/IWaypoint.java b/main/src/cgeo/geocaching/IWaypoint.java
index 5fbbfb4..870fb12 100644
--- a/main/src/cgeo/geocaching/IWaypoint.java
+++ b/main/src/cgeo/geocaching/IWaypoint.java
@@ -12,7 +12,7 @@ import cgeo.geocaching.geopoint.Geopoint;
*/
public interface IWaypoint extends ILogable {
- public abstract Integer getId();
+ public abstract int getId();
public abstract Geopoint getCoords();
diff --git a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
index 518fcb4..c1691f2 100644
--- a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
+++ b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java
@@ -131,10 +131,10 @@ public abstract class AbstractLocusApp extends AbstractApp {
if (locusId != NO_LOCUS_ID) {
pg.container = locusId;
}
- if (cache.getDifficulty() != null) {
+ if (cache.getDifficulty() > 0) {
pg.difficulty = cache.getDifficulty();
}
- if (cache.getTerrain() != null) {
+ if (cache.getTerrain() > 0) {
pg.terrain = cache.getTerrain();
}
pg.found = cache.isFound();
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java
index 77eeff4..8dcac64 100644
--- a/main/src/cgeo/geocaching/cgBase.java
+++ b/main/src/cgeo/geocaching/cgBase.java
@@ -968,13 +968,13 @@ public class cgBase {
// cache terrain
String result = BaseUtils.getMatch(tableInside, GCConstants.PATTERN_TERRAIN, true, null);
if (result != null) {
- cache.setTerrain(new Float(StringUtils.replaceChars(result, '_', '.')));
+ cache.setTerrain(Float.parseFloat(StringUtils.replaceChars(result, '_', '.')));
}
// cache difficulty
result = BaseUtils.getMatch(tableInside, GCConstants.PATTERN_DIFFICULTY, true, null);
if (result != null) {
- cache.setDifficulty(new Float(StringUtils.replaceChars(result, '_', '.')));
+ cache.setDifficulty(Float.parseFloat(StringUtils.replaceChars(result, '_', '.')));
}
// owner
@@ -1407,10 +1407,10 @@ public class cgBase {
if (StringUtils.isBlank(cache.getGuid())) {
Log.e(Settings.tag, "guid not parsed correctly");
}
- if (cache.getTerrain() == null || cache.getTerrain() == 0.0) {
+ if (cache.getTerrain() == 0.0) {
Log.e(Settings.tag, "terrain not parsed correctly");
}
- if (cache.getDifficulty() == null || cache.getDifficulty() == 0.0) {
+ if (cache.getDifficulty() == 0.0) {
Log.e(Settings.tag, "difficulty not parsed correctly");
}
if (StringUtils.isBlank(cache.getOwner())) {
@@ -1771,36 +1771,36 @@ public class cgBase {
return trackables;
}
- public static String getHumanDistance(final Float distance) {
- if (distance == null) {
+ public static String getHumanDistance(final Float distanceKilometers) {
+ if (distanceKilometers == null) {
return "?";
}
if (Settings.isUseMetricUnits()) {
- if (distance > 100) {
- return String.format("%.0f", Double.valueOf(Math.round(distance))) + " km";
- } else if (distance > 10) {
- return String.format("%.1f", Double.valueOf(Math.round(distance * 10.0) / 10.0)) + " km";
- } else if (distance > 1) {
- return String.format("%.2f", Double.valueOf(Math.round(distance * 100.0) / 100.0)) + " km";
- } else if (distance > 0.1) {
- return String.format("%.0f", Double.valueOf(Math.round(distance * 1000.0))) + " m";
- } else if (distance > 0.01) {
- return String.format("%.1f", Double.valueOf(Math.round(distance * 1000.0 * 10.0) / 10.0)) + " m";
+ if (distanceKilometers > 100) {
+ return String.format("%.0f", Double.valueOf(Math.round(distanceKilometers))) + " km";
+ } else if (distanceKilometers > 10) {
+ return String.format("%.1f", Double.valueOf(Math.round(distanceKilometers * 10.0) / 10.0)) + " km";
+ } else if (distanceKilometers > 1) {
+ return String.format("%.2f", Double.valueOf(Math.round(distanceKilometers * 100.0) / 100.0)) + " km";
+ } else if (distanceKilometers > 0.1) {
+ return String.format("%.0f", Double.valueOf(Math.round(distanceKilometers * 1000.0))) + " m";
+ } else if (distanceKilometers > 0.01) {
+ return String.format("%.1f", Double.valueOf(Math.round(distanceKilometers * 1000.0 * 10.0) / 10.0)) + " m";
} else {
- return String.format("%.2f", Double.valueOf(Math.round(distance * 1000.0 * 100.0) / 100.0)) + " m";
+ return String.format("%.2f", Double.valueOf(Math.round(distanceKilometers * 1000.0 * 100.0) / 100.0)) + " m";
}
} else {
- final Float miles = distance / IConversion.miles2km;
- if (distance > 100) {
+ final float miles = distanceKilometers / IConversion.miles2km;
+ if (distanceKilometers > 100) {
return String.format("%.0f", Double.valueOf(Math.round(miles))) + " mi";
- } else if (distance > 0.5) {
+ } else if (distanceKilometers > 0.5) {
return String.format("%.1f", Double.valueOf(Math.round(miles * 10.0) / 10.0)) + " mi";
- } else if (distance > 0.1) {
+ } else if (distanceKilometers > 0.1) {
return String.format("%.2f", Double.valueOf(Math.round(miles * 100.0) / 100.0)) + " mi";
- } else if (distance > 0.05) {
+ } else if (distanceKilometers > 0.05) {
return String.format("%.0f", Double.valueOf(Math.round(miles * 5280.0))) + " ft";
- } else if (distance > 0.01) {
+ } else if (distanceKilometers > 0.01) {
return String.format("%.1f", Double.valueOf(Math.round(miles * 5280 * 10.0) / 10.0)) + " ft";
} else {
return String.format("%.2f", Double.valueOf(Math.round(miles * 5280 * 100.0) / 100.0)) + " ft";
@@ -2645,7 +2645,7 @@ public class cgBase {
* @param xContentType
* @return
*/
- public static HttpResponse request(final String uri, final Parameters params, final Boolean xContentType) {
+ public static HttpResponse request(final String uri, final Parameters params, final boolean xContentType) {
final String fullUri = params == null ? uri : Uri.parse(uri).buildUpon().encodedQuery(params.toString()).build().toString();
final HttpRequestBase request = new HttpGet(fullUri);
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index a91737c..b89563b 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -45,10 +45,10 @@ public class cgCache implements ICache {
final public static int LOADOFFLINELOG = 1 << 5;
final public static int LOADALL = LOADATTRIBUTES | LOADWAYPOINTS | LOADSPOILERS | LOADLOGS | LOADINVENTORY | LOADOFFLINELOG;
- private Long updated = null;
- private Long detailedUpdate = null;
+ private long updated = 0;
+ private long detailedUpdate = 0;
private Long visitedDate = null;
- private Integer reason = 0;
+ private int reason = 0;
private boolean detailed = false;
private String geocode = "";
private String cacheId = "";
@@ -61,8 +61,8 @@ public class cgCache implements ICache {
private Date hidden = null;
private String hint = "";
private CacheSize size = null;
- private Float difficulty = Float.valueOf(0);
- private Float terrain = Float.valueOf(0);
+ private float difficulty = 0;
+ private float terrain = 0;
private Float direction = null;
private Float distance = null;
private String latlon = "";
@@ -119,7 +119,7 @@ public class cgCache implements ICache {
if (visitedDate == null || visitedDate == 0) {
visitedDate = other.getVisitedDate();
}
- if (reason == null || reason == 0) {
+ if (reason == 0) {
reason = other.reason;
}
if (StringUtils.isBlank(geocode)) {
@@ -155,10 +155,10 @@ public class cgCache implements ICache {
if (size == null) {
size = other.size;
}
- if (difficulty == null || difficulty == 0) {
+ if (difficulty == 0) {
difficulty = other.getDifficulty();
}
- if (terrain == null || terrain == 0) {
+ if (terrain == 0) {
terrain = other.getTerrain();
}
if (direction == null) {
@@ -384,7 +384,7 @@ public class cgCache implements ICache {
}
@Override
- public Float getDifficulty() {
+ public float getDifficulty() {
return difficulty;
}
@@ -414,7 +414,7 @@ public class cgCache implements ICache {
}
@Override
- public Float getTerrain() {
+ public float getTerrain() {
return terrain;
}
@@ -597,19 +597,19 @@ public class cgCache implements ICache {
return !((isEventCache() || isVirtual()) && size == CacheSize.NOT_CHOSEN);
}
- public Long getUpdated() {
+ public long getUpdated() {
return updated;
}
- public void setUpdated(Long updated) {
+ public void setUpdated(long updated) {
this.updated = updated;
}
- public Long getDetailedUpdate() {
+ public long getDetailedUpdate() {
return detailedUpdate;
}
- public void setDetailedUpdate(Long detailedUpdate) {
+ public void setDetailedUpdate(long detailedUpdate) {
this.detailedUpdate = detailedUpdate;
}
@@ -621,11 +621,11 @@ public class cgCache implements ICache {
this.visitedDate = visitedDate;
}
- public Integer getReason() {
+ public int getReason() {
return reason;
}
- public void setReason(Integer reason) {
+ public void setReason(int reason) {
this.reason = reason;
}
@@ -855,11 +855,11 @@ public class cgCache implements ICache {
this.size = size;
}
- public void setDifficulty(Float difficulty) {
+ public void setDifficulty(float difficulty) {
this.difficulty = difficulty;
}
- public void setTerrain(Float terrain) {
+ public void setTerrain(float terrain) {
this.terrain = terrain;
}
@@ -927,11 +927,11 @@ public class cgCache implements ICache {
}
public boolean hasDifficulty() {
- return difficulty != null && difficulty > 0f;
+ return difficulty > 0f;
}
public boolean hasTerrain() {
- return terrain != null && terrain > 0f;
+ return terrain > 0f;
}
}
diff --git a/main/src/cgeo/geocaching/cgCacheListAdapter.java b/main/src/cgeo/geocaching/cgCacheListAdapter.java
index 7f67bc6..48cc5cb 100644
--- a/main/src/cgeo/geocaching/cgCacheListAdapter.java
+++ b/main/src/cgeo/geocaching/cgCacheListAdapter.java
@@ -526,20 +526,22 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> {
} else {
favoriteBack = R.drawable.favourite_background_dark;
}
- if (cache.getMyVote() != null && cache.getMyVote() > 0) {
- if (cache.getMyVote() >= 4) {
+ if (cache.getMyVote() != null) {
+ float myVote = cache.getMyVote();
+ if (myVote >= 4) {
favoriteBack = ratingBcgs[2];
- } else if (cache.getMyVote() >= 3) {
+ } else if (myVote >= 3) {
favoriteBack = ratingBcgs[1];
- } else if (cache.getMyVote() > 0) {
+ } else if (myVote > 0) {
favoriteBack = ratingBcgs[0];
}
- } else if (cache.getRating() != null && cache.getRating() > 0) {
- if (cache.getRating() >= 3.5) {
+ } else if (cache.getRating() != null) {
+ float rating = cache.getRating();
+ if (rating >= 3.5) {
favoriteBack = ratingBcgs[2];
- } else if (cache.getRating() >= 2.1) {
+ } else if (rating >= 2.1) {
favoriteBack = ratingBcgs[1];
- } else if (cache.getRating() > 0.0) {
+ } else if (rating > 0.0) {
favoriteBack = ratingBcgs[0];
}
}
@@ -586,7 +588,7 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> {
}
cacheInfo.append(res.getString(R.string.cache_premium));
}
- if (cache.getReason() != null && cache.getReason() == 1) {
+ if (cache.getReason() == 1) {
if (cacheInfo.length() > 0) {
cacheInfo.append(SEPARATOR);
}
diff --git a/main/src/cgeo/geocaching/cgCoord.java b/main/src/cgeo/geocaching/cgCoord.java
index f6d7558..010fc22 100644
--- a/main/src/cgeo/geocaching/cgCoord.java
+++ b/main/src/cgeo/geocaching/cgCoord.java
@@ -7,7 +7,7 @@ import cgeo.geocaching.geopoint.Geopoint;
public class cgCoord implements IBasicCache, IWaypoint {
- private Integer id = null; // only valid if constructed with a waypoint
+ private int id = 0; // only valid if constructed with a waypoint
private WaypointType waypointType = null; // only valid if constructed with a waypoint
private String guid = null; // only valid if constructed with a cache
private CacheType cacheType = null; // only valid if constructed with a cache
@@ -18,8 +18,8 @@ public class cgCoord implements IBasicCache, IWaypoint {
private boolean found = false;
private boolean disabled = false;
private Geopoint coords = new Geopoint(0, 0);
- private Float difficulty = null;
- private Float terrain = null;
+ private float difficulty = 0;
+ private float terrain = 0;
private CacheSize size = null;
public cgCoord() {
@@ -52,11 +52,11 @@ public class cgCoord implements IBasicCache, IWaypoint {
waypointType = waypoint.getWaypointType();
}
- public Integer getId() {
+ public int getId() {
return id;
}
- public void setId(Integer id) {
+ public void setId(int id) {
this.id = id;
}
@@ -121,20 +121,20 @@ public class cgCoord implements IBasicCache, IWaypoint {
}
@Override
- public Float getDifficulty() {
+ public float getDifficulty() {
return difficulty;
}
- public void setDifficulty(Float difficulty) {
+ public void setDifficulty(float difficulty) {
this.difficulty = difficulty;
}
@Override
- public Float getTerrain() {
+ public float getTerrain() {
return terrain;
}
- public void setTerrain(Float terrain) {
+ public void setTerrain(float terrain) {
this.terrain = terrain;
}
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index c70e8c4..96bb811 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -1221,7 +1221,7 @@ public class cgData {
ContentValues values = new ContentValues();
- if (cache.getUpdated() == null) {
+ if (cache.getUpdated() == 0) {
values.put("updated", System.currentTimeMillis());
} else {
values.put("updated", cache.getUpdated());
@@ -2151,8 +2151,8 @@ public class cgData {
return attributes;
}
- public cgWaypoint loadWaypoint(Integer id) {
- if (id == null || id == 0) {
+ public cgWaypoint loadWaypoint(int id) {
+ if (id == 0) {
return null;
}
diff --git a/main/src/cgeo/geocaching/cgGeo.java b/main/src/cgeo/geocaching/cgGeo.java
index 19ffdf2..edeb1b6 100644
--- a/main/src/cgeo/geocaching/cgGeo.java
+++ b/main/src/cgeo/geocaching/cgGeo.java
@@ -32,7 +32,7 @@ public class cgGeo {
public Double altitudeNow = null;
public Float bearingNow = null;
public Float speedNow = null;
- public Float accuracyNow = null;
+ public float accuracyNow = -1f;
public int satellitesVisible = 0;
public int satellitesFixed = 0;
diff --git a/main/src/cgeo/geocaching/cgWaypoint.java b/main/src/cgeo/geocaching/cgWaypoint.java
index d8db277..ba49a97 100644
--- a/main/src/cgeo/geocaching/cgWaypoint.java
+++ b/main/src/cgeo/geocaching/cgWaypoint.java
@@ -12,7 +12,8 @@ import java.util.List;
public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
- private Integer id = 0;
+ private static final int ORDER_UNDEFINED = -2;
+ private int id = 0;
private String geocode = "geocode";
private WaypointType waypointType = WaypointType.WAYPOINT;
private String prefix = "";
@@ -21,7 +22,7 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
private String latlon = "";
private Geopoint coords = null;
private String note = "";
- private Integer cachedOrder = null;
+ private int cachedOrder = ORDER_UNDEFINED;
/**
* default constructor, no fields are set
@@ -123,7 +124,7 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
}
private int order() {
- if (cachedOrder == null) {
+ if (cachedOrder == ORDER_UNDEFINED) {
cachedOrder = computeOrder();
}
return cachedOrder;
@@ -140,18 +141,18 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
public void setPrefix(String prefix) {
this.prefix = prefix;
- cachedOrder = null;
+ cachedOrder = ORDER_UNDEFINED;
}
public String getUrl() {
return "http://coord.info/" + geocode.toUpperCase();
}
- public Integer getId() {
+ public int getId() {
return id;
}
- public void setId(Integer id) {
+ public void setId(int id) {
this.id = id;
}
@@ -211,11 +212,11 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> {
this.note = note;
}
- public Integer getCachedOrder() {
+ public int getCachedOrder() {
return cachedOrder;
}
- public void setCachedOrder(Integer cachedOrder) {
+ public void setCachedOrder(int cachedOrder) {
this.cachedOrder = cachedOrder;
}
diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java
index 0d44ad8..525d935 100644
--- a/main/src/cgeo/geocaching/cgeo.java
+++ b/main/src/cgeo/geocaching/cgeo.java
@@ -571,7 +571,7 @@ public class cgeo extends AbstractActivity {
navSatellites.setText(satellites);
navType.setText(res.getString(geo.locationProvider.resourceId));
- if (geo.accuracyNow != null) {
+ if (geo.accuracyNow >= 0) {
if (Settings.isUseMetricUnits()) {
navAccuracy.setText("±" + String.format("%.0f", geo.accuracyNow) + " m");
} else {
diff --git a/main/src/cgeo/geocaching/cgeoaddresses.java b/main/src/cgeo/geocaching/cgeoaddresses.java
index 8cf68fe..769e84d 100644
--- a/main/src/cgeo/geocaching/cgeoaddresses.java
+++ b/main/src/cgeo/geocaching/cgeoaddresses.java
@@ -124,11 +124,11 @@ public class cgeoaddresses extends AbstractActivity {
private class buttonListener implements View.OnClickListener {
- private Double latitude = null;
- private Double longitude = null;
- private String address = null;
+ private final double latitude;
+ private final double longitude;
+ private final String address;
- public buttonListener(Double latitudeIn, Double longitudeIn, String addressIn) {
+ public buttonListener(double latitudeIn, double longitudeIn, String addressIn) {
latitude = latitudeIn;
longitude = longitudeIn;
address = addressIn;
diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java
index 839d365..cdd5b23 100644
--- a/main/src/cgeo/geocaching/cgeoapplication.java
+++ b/main/src/cgeo/geocaching/cgeoapplication.java
@@ -292,15 +292,15 @@ public class cgeoapplication extends Application {
return true;
}
- public static Integer getTotal(final cgSearch search) {
+ public static int getTotal(final cgSearch search) {
if (search == null) {
- return null;
+ return 0;
}
return search.totalCnt;
}
- public static Integer getCount(final cgSearch search) {
+ public static int getCount(final cgSearch search) {
if (search == null) {
return 0;
}
@@ -376,14 +376,6 @@ public class cgeoapplication extends Application {
return getStorage().allDetailedThere();
}
- public cgWaypoint getWaypointById(Integer id) {
- if (id == null || id == 0) {
- return null;
- }
-
- return getStorage().loadWaypoint(id);
- }
-
public List<Object> getBounds(String geocode) {
if (geocode == null) {
return null;
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index 8505252..db26870 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -205,8 +205,8 @@ public class cgeocaches extends AbstractListActivity {
showToast(res.getString(R.string.err_list_load_fail));
setMoreCaches(false);
} else {
- final Integer count = cgeoapplication.getTotal(search);
- setMoreCaches(count != null && count > 0 && cacheList != null && cacheList.size() < count && cacheList.size() < MAX_LIST_ITEMS);
+ final int count = cgeoapplication.getTotal(search);
+ setMoreCaches(count > 0 && cacheList != null && cacheList.size() < count && cacheList.size() < MAX_LIST_ITEMS);
}
if (cacheList != null && cgeoapplication.getError(search) == StatusCode.UNAPPROVED_LICENSE) {
@@ -296,8 +296,8 @@ public class cgeocaches extends AbstractListActivity {
showToast(res.getString(R.string.err_list_load_fail));
setMoreCaches(false);
} else {
- final Integer count = cgeoapplication.getTotal(search);
- setMoreCaches(count != null && count > 0 && cacheList != null && cacheList.size() < count && cacheList.size() < MAX_LIST_ITEMS);
+ final int count = cgeoapplication.getTotal(search);
+ setMoreCaches(count > 0 && cacheList != null && cacheList.size() < count && cacheList.size() < MAX_LIST_ITEMS);
}
if (cgeoapplication.getError(search) != null) {
@@ -835,7 +835,7 @@ public class cgeocaches extends AbstractListActivity {
Collections.sort(sortedLabels);
for (String label : sortedLabels) {
Integer id = comparators.get(label);
- subMenuSort.add(1, id, 0, label).setCheckable(true).setChecked(id == MENU_SORT_DISTANCE);
+ subMenuSort.add(1, id.intValue(), 0, label).setCheckable(true).setChecked(id.intValue() == MENU_SORT_DISTANCE);
}
subMenuSort.setGroupCheckable(1, true, true);
@@ -1469,8 +1469,8 @@ public class cgeocaches extends AbstractListActivity {
}
if (CollectionUtils.isNotEmpty(cacheList)) {
- final Integer count = cgeoapplication.getTotal(search);
- setMoreCaches(count != null && count > 0 && cacheList.size() < count && cacheList.size() < MAX_LIST_ITEMS);
+ final int count = cgeoapplication.getTotal(search);
+ setMoreCaches(count > 0 && cacheList.size() < count && cacheList.size() < MAX_LIST_ITEMS);
}
setTitle(title);
@@ -2710,7 +2710,7 @@ public class cgeocaches extends AbstractListActivity {
context.startActivity(cachesIntent);
}
- public static void startActivityAddress(Context context, Double latitude, Double longitude, String address) {
+ public static void startActivityAddress(Context context, double latitude, double longitude, String address) {
Intent addressIntent = new Intent(context, cgeocaches.class);
addressIntent.putExtra(EXTRAS_LIST_TYPE, CacheListType.ADDRESS);
addressIntent.putExtra("latitude", latitude);
diff --git a/main/src/cgeo/geocaching/cgeocoords.java b/main/src/cgeo/geocaching/cgeocoords.java
index 83d694c..367fb22 100644
--- a/main/src/cgeo/geocaching/cgeocoords.java
+++ b/main/src/cgeo/geocaching/cgeocoords.java
@@ -139,7 +139,7 @@ public class cgeocoords extends Dialog {
if (gp == null) {
return;
}
- Double lat = 0.0;
+ double lat = 0.0;
if (gp.getLatitude() < 0) {
bLat.setText("S");
} else {
@@ -148,7 +148,7 @@ public class cgeocoords extends Dialog {
lat = Math.abs(gp.getLatitude());
- Double lon = 0.0;
+ double lon = 0.0;
if (gp.getLongitude() < 0) {
bLon.setText("W");
} else {
@@ -379,8 +379,8 @@ public class cgeocoords extends Dialog {
int latDeg = 0, latMin = 0, latSec = 0;
int lonDeg = 0, lonMin = 0, lonSec = 0;
- Double latDegFrac = 0.0, latMinFrac = 0.0, latSecFrac = 0.0;
- Double lonDegFrac = 0.0, lonMinFrac = 0.0, lonSecFrac = 0.0;
+ double latDegFrac = 0.0, latMinFrac = 0.0, latSecFrac = 0.0;
+ double lonDegFrac = 0.0, lonMinFrac = 0.0, lonSecFrac = 0.0;
try {
latDeg = Integer.parseInt(eLatDeg.getText().toString());
diff --git a/main/src/cgeo/geocaching/cgeonavigate.java b/main/src/cgeo/geocaching/cgeonavigate.java
index ac9118e..71227f5 100644
--- a/main/src/cgeo/geocaching/cgeonavigate.java
+++ b/main/src/cgeo/geocaching/cgeonavigate.java
@@ -363,7 +363,7 @@ public class cgeonavigate extends AbstractActivity {
navSatellites.setText(satellites);
navType.setText(res.getString(geo.locationProvider.resourceId));
- if (geo.accuracyNow != null) {
+ if (geo.accuracyNow >= 0) {
if (Settings.isUseMetricUnits()) {
navAccuracy.setText("±" + String.format("%.0f", geo.accuracyNow) + " m");
} else {
diff --git a/main/src/cgeo/geocaching/cgeopopup.java b/main/src/cgeo/geocaching/cgeopopup.java
index 908b895..3071e80 100644
--- a/main/src/cgeo/geocaching/cgeopopup.java
+++ b/main/src/cgeo/geocaching/cgeopopup.java
@@ -410,7 +410,7 @@ public class cgeopopup extends AbstractActivity {
final Button offlineStore = (Button) findViewById(R.id.offline_store);
if (cache.getReason() > 0) {
- Long diff = (System.currentTimeMillis() / (60 * 1000)) - (cache.getDetailedUpdate() / (60 * 1000)); // minutes
+ long diff = (System.currentTimeMillis() / (60 * 1000)) - (cache.getDetailedUpdate() / (60 * 1000)); // minutes
String ago = "";
if (diff < 15) {
diff --git a/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java b/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java
index 83d6487..279097d 100644
--- a/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java
+++ b/main/src/cgeo/geocaching/connector/opencaching/OkapiClient.java
@@ -75,8 +75,9 @@ final public class OkapiClient {
final cgCache cache = parseCache(data);
- cache.setUpdated(new Date().getTime());
- cache.setDetailedUpdate(new Date().getTime());
+ long time = new Date().getTime();
+ cache.setUpdated(time);
+ cache.setDetailedUpdate(time);
return cache;
}
diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java
index 94140e6..8e530a7 100644
--- a/main/src/cgeo/geocaching/files/GPXParser.java
+++ b/main/src/cgeo/geocaching/files/GPXParser.java
@@ -536,8 +536,8 @@ public abstract class GPXParser extends FileParser {
@Override
public void end(String body) {
try {
- cache.setDifficulty(new Float(body));
- } catch (Exception e) {
+ cache.setDifficulty(Float.parseFloat(body));
+ } catch (NumberFormatException e) {
Log.w(Settings.tag, "Failed to parse difficulty: " + e.toString());
}
}
@@ -549,8 +549,8 @@ public abstract class GPXParser extends FileParser {
@Override
public void end(String body) {
try {
- cache.setTerrain(new Float(body));
- } catch (Exception e) {
+ cache.setTerrain(Float.parseFloat(body));
+ } catch (NumberFormatException e) {
Log.w(Settings.tag, "Failed to parse terrain: " + e.toString());
}
}
diff --git a/main/src/cgeo/geocaching/files/LocParser.java b/main/src/cgeo/geocaching/files/LocParser.java
index 14acbf6..bbf2d7a 100644
--- a/main/src/cgeo/geocaching/files/LocParser.java
+++ b/main/src/cgeo/geocaching/files/LocParser.java
@@ -100,11 +100,11 @@ public final class LocParser extends FileParser {
}
final Matcher matcherDifficulty = patternDifficulty.matcher(pointString);
if (matcherDifficulty.find()) {
- pointCoord.setDifficulty(new Float(matcherDifficulty.group(1).trim()));
+ pointCoord.setDifficulty(Float.parseFloat(matcherDifficulty.group(1).trim()));
}
final Matcher matcherTerrain = patternTerrain.matcher(pointString);
if (matcherTerrain.find()) {
- pointCoord.setTerrain(new Float(matcherTerrain.group(1).trim()));
+ pointCoord.setTerrain(Float.parseFloat(matcherTerrain.group(1).trim()));
}
final Matcher matcherContainer = patternContainer.matcher(pointString);
if (matcherContainer.find()) {
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index f354374..3999413 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -153,7 +153,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
private ProgressDialog waitDialog = null;
private int detailTotal = 0;
private int detailProgress = 0;
- private Long detailProgressTime = 0L;
+ private long detailProgressTime = 0L;
// views
private ImageSwitcher myLocSwitch = null;
// other things
diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java
index f1e0f97..35f12ae 100644
--- a/main/src/cgeo/geocaching/maps/CachesOverlay.java
+++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java
@@ -211,7 +211,7 @@ public class CachesOverlay extends AbstractItemizedOverlay {
popupIntent.putExtra("geocode", coordinate.getGeocode());
context.startActivity(popupIntent);
- } else if (coordinate.getCoordType() != null && coordinate.getCoordType().equalsIgnoreCase("waypoint") && coordinate.getId() != null && coordinate.getId() > 0) {
+ } else if (coordinate.getCoordType() != null && coordinate.getCoordType().equalsIgnoreCase("waypoint") && coordinate.getId() > 0) {
Intent popupIntent = new Intent(context, cgeowaypoint.class);
popupIntent.putExtra("waypoint", coordinate.getId());
diff --git a/main/src/cgeo/geocaching/sorting/DifficultyComparator.java b/main/src/cgeo/geocaching/sorting/DifficultyComparator.java
index c044598..0d65660 100644
--- a/main/src/cgeo/geocaching/sorting/DifficultyComparator.java
+++ b/main/src/cgeo/geocaching/sorting/DifficultyComparator.java
@@ -10,7 +10,7 @@ public class DifficultyComparator extends AbstractCacheComparator {
@Override
protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return cache1.getDifficulty() != null && cache2.getDifficulty() != null;
+ return cache1.getDifficulty() != 0.0 && cache2.getDifficulty() != 0.0;
}
@Override
diff --git a/main/src/cgeo/geocaching/sorting/FindsComparator.java b/main/src/cgeo/geocaching/sorting/FindsComparator.java
index 983946f..3895273 100644
--- a/main/src/cgeo/geocaching/sorting/FindsComparator.java
+++ b/main/src/cgeo/geocaching/sorting/FindsComparator.java
@@ -31,7 +31,7 @@ public class FindsComparator extends AbstractCacheComparator {
}
Integer logged = cache.getLogCounts().get(cgBase.LOG_FOUND_IT);
if (logged != null) {
- finds = logged;
+ finds = logged.intValue();
}
return finds;
}
diff --git a/main/src/cgeo/geocaching/sorting/TerrainComparator.java b/main/src/cgeo/geocaching/sorting/TerrainComparator.java
index 2da5971..c0590cb 100644
--- a/main/src/cgeo/geocaching/sorting/TerrainComparator.java
+++ b/main/src/cgeo/geocaching/sorting/TerrainComparator.java
@@ -10,7 +10,7 @@ public class TerrainComparator extends AbstractCacheComparator {
@Override
protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return cache1.getTerrain() != null && cache2.getTerrain() != null;
+ return cache1.getTerrain() != 0.0 && cache2.getTerrain() != 0.0;
}
@Override