diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2012-12-18 22:09:03 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2012-12-18 22:09:03 +0100 |
| commit | dfa622b179876ce94b3eb74c8623b4451adbbfd9 (patch) | |
| tree | 2c8f22a7b120d07f6f1656dbb53b47edfa5d57a6 | |
| parent | 5368032229c7695acb499f0461b97c2ad359b7ff (diff) | |
| download | cgeo-dfa622b179876ce94b3eb74c8623b4451adbbfd9.zip cgeo-dfa622b179876ce94b3eb74c8623b4451adbbfd9.tar.gz cgeo-dfa622b179876ce94b3eb74c8623b4451adbbfd9.tar.bz2 | |
Refactoring: use isEmpty() where appropriate
| -rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/EditWaypointActivity.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/VisitCacheActivity.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgWaypoint.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeotrackable.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCParser.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/Login.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/files/FileList.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/geopoint/DistanceParser.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java | 2 |
13 files changed, 15 insertions, 15 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 198f292..dee4750 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -2183,7 +2183,7 @@ public class CacheDetailActivity extends AbstractActivity { } } - if (sortedLogCounts.size() > 0) { + if (!sortedLogCounts.isEmpty()) { // sort the log counts by type id ascending. that way the FOUND, DNF log types are the first and most visible ones Collections.sort(sortedLogCounts, new Comparator<Entry<LogType, Integer>>() { diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java index 5646794..a5b445f 100644 --- a/main/src/cgeo/geocaching/EditWaypointActivity.java +++ b/main/src/cgeo/geocaching/EditWaypointActivity.java @@ -407,7 +407,7 @@ public class EditWaypointActivity extends AbstractActivity { String name = ((EditText) findViewById(R.id.name)).getText().toString().trim(); // if no name is given, just give the waypoint its number as name - if (name.length() == 0) { + if (name.isEmpty()) { name = res.getString(R.string.waypoint) + " " + String.valueOf(wpCount + 1); } final String note = ((EditText) findViewById(R.id.note)).getText().toString().trim(); diff --git a/main/src/cgeo/geocaching/VisitCacheActivity.java b/main/src/cgeo/geocaching/VisitCacheActivity.java index 76018c0..7685496 100644 --- a/main/src/cgeo/geocaching/VisitCacheActivity.java +++ b/main/src/cgeo/geocaching/VisitCacheActivity.java @@ -717,7 +717,7 @@ public class VisitCacheActivity extends AbstractLoggingActivity implements DateD // Do not erase the saved log if the user has removed all the characters // without using "Clear". This may be a manipulation mistake, and erasing // again will be easy using "Clear" while retyping the text may not be. - if (force || (log.length() > 0 && !StringUtils.equals(log, text))) { + if (force || (!log.isEmpty() && !StringUtils.equals(log, text))) { cache.logOffline(this, log, date, typeSelected); } text = log; diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index 685cbe0..f025f05 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -310,7 +310,7 @@ public class cgCache implements ICache, IWaypoint { if (logs.isEmpty()) { // keep last known logs if none logs.set(other.logs); } - if (logCounts.size() == 0) { + if (logCounts.isEmpty()) { logCounts = other.logCounts; } diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index 416058a..12b63dd 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -2842,7 +2842,7 @@ public class cgData { private static String whereGeocodeIn(Set<String> geocodes) { final StringBuilder where = new StringBuilder(); - if (geocodes != null && geocodes.size() > 0) { + if (geocodes != null && !geocodes.isEmpty()) { StringBuilder all = new StringBuilder(); for (String geocode : geocodes) { if (all.length() > 0) { diff --git a/main/src/cgeo/geocaching/cgWaypoint.java b/main/src/cgeo/geocaching/cgWaypoint.java index 32cc526..72b15f7 100644 --- a/main/src/cgeo/geocaching/cgWaypoint.java +++ b/main/src/cgeo/geocaching/cgWaypoint.java @@ -86,7 +86,7 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> { for (cgWaypoint old : oldPoints) { if (old != null) { boolean merged = false; - if (old.name != null && old.name.length() > 0) { + if (old.name != null && !old.name.isEmpty()) { for (cgWaypoint waypoint : newPoints) { if (waypoint != null && waypoint.name != null) { if (old.name.equalsIgnoreCase(waypoint.name)) { diff --git a/main/src/cgeo/geocaching/cgeotrackable.java b/main/src/cgeo/geocaching/cgeotrackable.java index 3c9e554..5aa6675 100644 --- a/main/src/cgeo/geocaching/cgeotrackable.java +++ b/main/src/cgeo/geocaching/cgeotrackable.java @@ -506,7 +506,7 @@ public class cgeotrackable extends AbstractActivity { listView.addView(rowView); } - if (trackable.getLogs().size() > 0) { + if (!trackable.getLogs().isEmpty()) { findViewById(R.id.log_box).setVisibility(View.VISIBLE); } } diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index 6ee0516..170bce3 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -243,7 +243,7 @@ public abstract class GCParser { recaptchaText = thread.getText(); } - if (cids.size() > 0 && (Settings.isPremiumMember() || showCaptcha) && (recaptchaChallenge == null || StringUtils.isNotBlank(recaptchaText))) { + if (!cids.isEmpty() && (Settings.isPremiumMember() || showCaptcha) && (recaptchaChallenge == null || StringUtils.isNotBlank(recaptchaText))) { Log.i("Trying to get .loc for " + cids.size() + " caches"); try { @@ -511,7 +511,7 @@ public abstract class GCParser { // if the image name can be recognized, use the image name as attribute String imageName = matcherAttributesInside.group(1).trim(); - if (imageName.length() > 0) { + if (!imageName.isEmpty()) { int start = imageName.lastIndexOf('/'); int end = imageName.lastIndexOf('.'); if (start >= 0 && end >= 0) { diff --git a/main/src/cgeo/geocaching/connector/gc/Login.java b/main/src/cgeo/geocaching/connector/gc/Login.java index c3f29cc..093de7b 100644 --- a/main/src/cgeo/geocaching/connector/gc/Login.java +++ b/main/src/cgeo/geocaching/connector/gc/Login.java @@ -365,7 +365,7 @@ public abstract class Login { final Matcher matcherViewstates = GCConstants.PATTERN_VIEWSTATES.matcher(page); while (matcherViewstates.find()) { String sno = matcherViewstates.group(1); // number of viewstate - if (sno.length() == 0) { + if (sno.isEmpty()) { no = 0; } else { diff --git a/main/src/cgeo/geocaching/files/FileList.java b/main/src/cgeo/geocaching/files/FileList.java index df95085..fdda069 100644 --- a/main/src/cgeo/geocaching/files/FileList.java +++ b/main/src/cgeo/geocaching/files/FileList.java @@ -284,7 +284,7 @@ public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractLis extensions = extensionsIn; for (int i = 0; i < extensions.length; i++) { String extension = extensions[i]; - if (extension.length() == 0 || extension.charAt(0) != '.') { + if (extension.isEmpty() || extension.charAt(0) != '.') { extensions[i] = "." + extension; } } diff --git a/main/src/cgeo/geocaching/geopoint/DistanceParser.java b/main/src/cgeo/geocaching/geopoint/DistanceParser.java index 61d1ecd..9f9ad02 100644 --- a/main/src/cgeo/geocaching/geopoint/DistanceParser.java +++ b/main/src/cgeo/geocaching/geopoint/DistanceParser.java @@ -29,7 +29,7 @@ public final class DistanceParser { final float value = Float.parseFloat(matcher.group(1).replace(',', '.')); final String unit = matcher.group(2).toLowerCase(Locale.US); - if (unit.equals("m") || (unit.length() == 0 && metricUnit)) { + if (unit.equals("m") || (unit.isEmpty() && metricUnit)) { return value / 1000; } if (unit.equals("km")) { diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 1f682cc..71d9c73 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -227,7 +227,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } countVisibleCaches(); - if (caches != null && caches.size() > 0 && !mapTitle.contains("[")) { + if (caches != null && !caches.isEmpty() && !mapTitle.contains("[")) { title.append(" [").append(cachesCnt); if (cachesCnt != caches.size()) { title.append('/').append(caches.size()); @@ -339,7 +339,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto final List<cgCache> protectedCaches = caches.getAsList(); int count = 0; - if (protectedCaches.size() > 0) { + if (!protectedCaches.isEmpty()) { final Viewport viewport = mapView.getViewport(); for (final cgCache cache : protectedCaches) { diff --git a/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java b/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java index 22ee0fb..36de104 100644 --- a/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java +++ b/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java @@ -242,7 +242,7 @@ public class TwitterAuthorizationActivity extends AbstractActivity { @Override public void onClick(View arg0) { - if (((EditText) findViewById(R.id.pin)).getText().toString().length() == 0) { + if (((EditText) findViewById(R.id.pin)).getText().toString().isEmpty()) { helpDialog(res.getString(R.string.auth_dialog_pin_title), res.getString(R.string.auth_dialog_pin_message)); return; } |
