diff options
Diffstat (limited to 'src/cgeo/geocaching/cgeovisit.java')
| -rw-r--r-- | src/cgeo/geocaching/cgeovisit.java | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/cgeo/geocaching/cgeovisit.java b/src/cgeo/geocaching/cgeovisit.java index c26dba4..924ea7f 100644 --- a/src/cgeo/geocaching/cgeovisit.java +++ b/src/cgeo/geocaching/cgeovisit.java @@ -6,6 +6,9 @@ import java.util.Date; import java.util.HashMap; import java.util.Locale; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.StringUtils; + import android.app.Dialog; import android.app.ProgressDialog; import android.content.Intent; @@ -26,6 +29,7 @@ import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import cgeo.geocaching.LogTemplateProvider.LogTemplate; +import cgeo.geocaching.utils.CollectionUtils; public class cgeovisit extends cgLogForm { static final String EXTRAS_FOUND = "found"; @@ -79,7 +83,7 @@ public class cgeovisit extends cgLogForm { showToast(res.getString(R.string.info_log_type_changed)); } - if (cgBase.isEmpty(viewstates) && attempts < 2) { + if (ArrayUtils.isEmpty(viewstates) && attempts < 2) { showToast(res.getString(R.string.err_log_load_data_again)); loadData thread; @@ -87,7 +91,7 @@ public class cgeovisit extends cgLogForm { thread.start(); return; - } else if (cgBase.isEmpty(viewstates) && attempts >= 2) { + } else if (ArrayUtils.isEmpty(viewstates) && attempts >= 2) { showToast(res.getString(R.string.err_log_load_data)); showProgress(false); @@ -103,7 +107,7 @@ public class cgeovisit extends cgLogForm { post.setOnClickListener(new postListener()); // add trackables - if (trackables != null && trackables.isEmpty() == false) { + if (CollectionUtils.isNotEmpty(trackables)) { if (inflater == null) { inflater = getLayoutInflater(); } @@ -234,16 +238,16 @@ public class cgeovisit extends cgLogForm { alreadyFound = extras.getBoolean(EXTRAS_FOUND); } - if ((cacheid == null || cacheid.length() == 0) && geocode != null && geocode.length() > 0) { + if ((StringUtils.isBlank(cacheid)) && StringUtils.isNotBlank(geocode)) { cacheid = app.getCacheid(geocode); } - if ((geocode == null || geocode.length() == 0) && cacheid != null && cacheid.length() > 0) { + if ((StringUtils.isBlank(geocode)) && StringUtils.isNotBlank(cacheid)) { geocode = app.getGeocode(cacheid); } cache = app.getCacheByGeocode(geocode); - if (cache.name != null && cache.name.length() > 0) { + if (StringUtils.isNotBlank(cache.name)) { setTitle(res.getString(R.string.log_new_log) + " " + cache.name); } else { setTitle(res.getString(R.string.log_new_log) + " " + cache.geocode.toUpperCase()); @@ -305,7 +309,7 @@ public class cgeovisit extends cgLogForm { boolean signatureAvailable = settings.getSignature() != null; menu.findItem(MENU_SIGNATURE).setVisible(signatureAvailable); - boolean voteAvailable = settings.isGCvoteLogin() && typeSelected == cgBase.LOG_FOUND_IT && cache.guid != null && cache.guid.length() > 0; + boolean voteAvailable = settings.isGCvoteLogin() && typeSelected == cgBase.LOG_FOUND_IT && StringUtils.isNotBlank(cache.guid); menu.findItem(SUBMENU_VOTE).setVisible(voteAvailable); return true; @@ -318,7 +322,7 @@ public class cgeovisit extends cgLogForm { if (id == MENU_SIGNATURE) { EditText log = (EditText) findViewById(R.id.log); String content = log.getText().toString(); - if (content.length() > 0) { + if (StringUtils.isNotBlank(content)) { insertIntoLog("\n"); } insertIntoLog(LogTemplateProvider.applyTemplates(settings.getSignature(), base)); @@ -355,7 +359,7 @@ public class cgeovisit extends cgLogForm { } public boolean setRating(String guid, double vote) { - if (guid == null || guid.length() == 0) { + if (StringUtils.isBlank(guid)) { return false; } if (vote < 0.0 || vote > 5.0) { @@ -498,10 +502,9 @@ public class cgeovisit extends cgLogForm { } post.setText(res.getString(R.string.log_post_no_rate)); } - } else if (settings.getSignature() != null + } else if (StringUtils.isNotBlank(settings.getSignature()) && settings.signatureAutoinsert - && settings.getSignature().length() > 0 - && 0 == ((EditText) findViewById(R.id.log)).getText().length()) { + && StringUtils.isBlank(((EditText) findViewById(R.id.log)).getText())) { insertIntoLog(LogTemplateProvider.applyTemplates(settings.getSignature(), base)); } @@ -529,7 +532,7 @@ public class cgeovisit extends cgLogForm { dateButton.setOnClickListener(new cgeovisitDateListener()); EditText logView = (EditText) findViewById(R.id.log); - if (logView.getText().length() == 0 && text != null && text.length() > 0) { + if (StringUtils.isBlank(logView.getText()) && StringUtils.isNotBlank(text) ) { logView.setText(text); } @@ -545,7 +548,7 @@ public class cgeovisit extends cgLogForm { if (post == null) { post = (Button) findViewById(R.id.post); } - if (cgBase.isEmpty(viewstates)) { + if (ArrayUtils.isEmpty(viewstates)) { post.setEnabled(false); post.setOnTouchListener(null); post.setOnClickListener(null); @@ -670,7 +673,7 @@ public class cgeovisit extends cgLogForm { dateButton.setOnClickListener(new cgeovisitDateListener()); EditText logView = (EditText) findViewById(R.id.log); - if (text != null && text.length() > 0) { + if (StringUtils.isNotBlank(text)) { logView.setText(text); } else { logView.setText(""); @@ -705,7 +708,7 @@ public class cgeovisit extends cgLogForm { attempts++; try { - if (cacheid != null && cacheid.length() > 0) { + if (StringUtils.isNotBlank(cacheid)) { params.put("ID", cacheid); } else { loadDataHandler.sendEmptyMessage(0); @@ -718,7 +721,7 @@ public class cgeovisit extends cgLogForm { trackables = cgBase.parseTrackableLog(page); final ArrayList<Integer> typesPre = cgBase.parseTypes(page); - if (typesPre.size() > 0) { + if (CollectionUtils.isNotEmpty(typesPre)) { types.clear(); types.addAll(typesPre); types.remove(Integer.valueOf(cgBase.LOG_UPDATE_COORDINATES)); @@ -799,8 +802,8 @@ public class cgeovisit extends cgLogForm { if ( status == 1 && typeSelected == cgBase.LOG_FOUND_IT && settings.twitter == 1 - && settings.tokenPublic != null && settings.tokenPublic.length() > 0 && settings.tokenSecret != null - && settings.tokenSecret.length() > 0 && tweetCheck.isChecked() && tweetBox.getVisibility() == View.VISIBLE + && StringUtils.isNotBlank(settings.tokenPublic) && StringUtils.isNotBlank(settings.tokenSecret) + && tweetCheck.isChecked() && tweetBox.getVisibility() == View.VISIBLE ) { cgBase.postTweetCache(app, settings, geocode); } |
