aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2012-12-19 08:46:52 +0100
committerSamuel Tardieu <sam@rfc1149.net>2012-12-19 08:46:52 +0100
commit13f406f1d3165496ccc713dc797ed40b33727ba7 (patch)
treecbe65f4ed8ea7ab9ef06a4ce073614029c8762fa
parentdd59146e7197c32869971a02474e1107f8dc515b (diff)
downloadcgeo-13f406f1d3165496ccc713dc797ed40b33727ba7.zip
cgeo-13f406f1d3165496ccc713dc797ed40b33727ba7.tar.gz
cgeo-13f406f1d3165496ccc713dc797ed40b33727ba7.tar.bz2
Fix: do not use String#isEmpty()
String#isEmpty() has been introduced on SDK API 9 only. For earlier versions of Android, StringUtils.isEmpty/isNotEmpty can be used instead.
-rw-r--r--main/src/cgeo/geocaching/EditWaypointActivity.java2
-rw-r--r--main/src/cgeo/geocaching/VisitCacheActivity.java2
-rw-r--r--main/src/cgeo/geocaching/cgWaypoint.java2
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java4
-rw-r--r--main/src/cgeo/geocaching/connector/gc/Login.java5
-rw-r--r--main/src/cgeo/geocaching/files/FileList.java4
-rw-r--r--main/src/cgeo/geocaching/geopoint/DistanceParser.java4
-rw-r--r--main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java2
8 files changed, 13 insertions, 12 deletions
diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java
index 136cc6f..89c9d11 100644
--- a/main/src/cgeo/geocaching/EditWaypointActivity.java
+++ b/main/src/cgeo/geocaching/EditWaypointActivity.java
@@ -406,7 +406,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.isEmpty()) {
+ if (StringUtils.isEmpty(name)) {
name = res.getString(R.string.waypoint) + " " + (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 7685496..8f2c79a 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.isEmpty() && !StringUtils.equals(log, text))) {
+ if (force || (StringUtils.isNotEmpty(log) && !StringUtils.equals(log, text))) {
cache.logOffline(this, log, date, typeSelected);
}
text = log;
diff --git a/main/src/cgeo/geocaching/cgWaypoint.java b/main/src/cgeo/geocaching/cgWaypoint.java
index 72b15f7..4b7b95e 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.isEmpty()) {
+ if (StringUtils.isNotEmpty(old.name)) {
for (cgWaypoint waypoint : newPoints) {
if (waypoint != null && waypoint.name != null) {
if (old.name.equalsIgnoreCase(waypoint.name)) {
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 840afb0..78064bb 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -509,8 +509,8 @@ public abstract class GCParser {
String attribute = matcherAttributesInside.group(2).toLowerCase(Locale.US);
// if the image name can be recognized, use the image name as attribute
- String imageName = matcherAttributesInside.group(1).trim();
- if (!imageName.isEmpty()) {
+ final String imageName = matcherAttributesInside.group(1).trim();
+ if (StringUtils.isNotEmpty(imageName)) {
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 0ce385c..494bcee 100644
--- a/main/src/cgeo/geocaching/connector/gc/Login.java
+++ b/main/src/cgeo/geocaching/connector/gc/Login.java
@@ -365,10 +365,9 @@ public abstract class Login {
while (matcherViewstates.find()) {
String sno = matcherViewstates.group(1); // number of viewstate
int no;
- if (sno.isEmpty()) {
+ if (StringUtils.isEmpty(sno)) {
no = 0;
- }
- else {
+ } else {
try {
no = Integer.parseInt(sno);
} catch (NumberFormatException e) {
diff --git a/main/src/cgeo/geocaching/files/FileList.java b/main/src/cgeo/geocaching/files/FileList.java
index fdda069..19d3305 100644
--- a/main/src/cgeo/geocaching/files/FileList.java
+++ b/main/src/cgeo/geocaching/files/FileList.java
@@ -283,8 +283,8 @@ public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractLis
private void setExtensions(final String[] extensionsIn) {
extensions = extensionsIn;
for (int i = 0; i < extensions.length; i++) {
- String extension = extensions[i];
- if (extension.isEmpty() || extension.charAt(0) != '.') {
+ final String extension = extensions[i];
+ if (StringUtils.isEmpty(extension) || 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 9f9ad02..d8db8e4 100644
--- a/main/src/cgeo/geocaching/geopoint/DistanceParser.java
+++ b/main/src/cgeo/geocaching/geopoint/DistanceParser.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.geopoint;
+import org.apache.commons.lang3.StringUtils;
+
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -29,7 +31,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.isEmpty() && metricUnit)) {
+ if (unit.equals("m") || (StringUtils.isEmpty(unit) && metricUnit)) {
return value / 1000;
}
if (unit.equals("km")) {
diff --git a/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java b/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java
index d1242e8..e8eeb1f 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().isEmpty()) {
+ if (StringUtils.isEmpty(((EditText) findViewById(R.id.pin).getText().toString())) {
helpDialog(res.getString(R.string.auth_dialog_pin_title), res.getString(R.string.auth_dialog_pin_message));
return;
}