mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
use more idiomatic String.isEmpty() instead of comparing length to 0
This commit is contained in:
parent
df75853c64
commit
cbbd0bc405
@ -137,7 +137,7 @@ public abstract class AccountList extends K9ListActivity implements OnItemClickL
|
||||
holder.email.setText(account.getEmail());
|
||||
}
|
||||
|
||||
if (description == null || description.length() == 0) {
|
||||
if (description == null || description.isEmpty()) {
|
||||
description = account.getEmail();
|
||||
}
|
||||
|
||||
|
@ -1735,7 +1735,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
||||
}
|
||||
|
||||
String description = account.getDescription();
|
||||
if (description == null || description.length() == 0) {
|
||||
if (description == null || description.isEmpty()) {
|
||||
description = account.getEmail();
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class ChooseIdentity extends K9ListActivity {
|
||||
identities = mAccount.getIdentities();
|
||||
for (Identity identity : identities) {
|
||||
String description = identity.getDescription();
|
||||
if (description == null || description.trim().length() == 0) {
|
||||
if (description == null || description.trim().isEmpty()) {
|
||||
description = getString(R.string.message_view_from_format, identity.getName(), identity.getEmail());
|
||||
}
|
||||
adapter.add(description);
|
||||
|
@ -40,7 +40,7 @@ public class LauncherShortcuts extends AccountList {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
|
||||
String description = account.getDescription();
|
||||
if (description == null || description.length() == 0) {
|
||||
if (description == null || description.isEmpty()) {
|
||||
description = account.getEmail();
|
||||
}
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, description);
|
||||
|
@ -57,7 +57,7 @@ public class DomainNameChecker {
|
||||
*/
|
||||
public static boolean match(X509Certificate certificate, String thisDomain) {
|
||||
if ((certificate == null) || (thisDomain == null)
|
||||
|| (thisDomain.length() == 0)) {
|
||||
|| thisDomain.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class DomainNameChecker {
|
||||
* @return True iff the domain name is specified as an IP address
|
||||
*/
|
||||
private static boolean isIpAddress(String domain) {
|
||||
if ((domain == null) || (domain.length() == 0)) {
|
||||
if ((domain == null) || domain.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -210,8 +210,8 @@ public class DomainNameChecker {
|
||||
+ thatDomain);
|
||||
}
|
||||
|
||||
if ((thisDomain == null) || (thisDomain.length() == 0)
|
||||
|| (thatDomain == null) || (thatDomain.length() == 0)) {
|
||||
if ((thisDomain == null) || thisDomain.isEmpty()
|
||||
|| (thatDomain == null) || thatDomain.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.fsck.k9.helper;
|
||||
public final class StringUtils {
|
||||
|
||||
public static boolean isNullOrEmpty(String string){
|
||||
return string == null || string.length() == 0;
|
||||
return string == null || string.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean containsAny(String haystack, String[] needles) {
|
||||
|
@ -176,7 +176,7 @@ public class DecoderUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (encodedText.length() == 0) {
|
||||
if (encodedText.isEmpty()) {
|
||||
Log.w(K9.LOG_TAG, "Missing encoded text in encoded word: '" + body.substring(begin, end) + "'");
|
||||
return null;
|
||||
}
|
||||
|
@ -1059,7 +1059,7 @@ public class MimeUtility {
|
||||
in.read(buf, 0, buf.length);
|
||||
String str = new String(buf, "US-ASCII");
|
||||
|
||||
if (str.length() == 0) {
|
||||
if (str.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
Pattern p = Pattern.compile("<meta http-equiv=\"?Content-Type\"? content=\"text/html; charset=(.+?)\">", Pattern.CASE_INSENSITIVE);
|
||||
@ -3426,9 +3426,9 @@ public class MimeUtility {
|
||||
BodyPart bodyPart = multipart.getBodyPart(i);
|
||||
String bodyText = getTextFromPart(bodyPart);
|
||||
if (bodyText != null) {
|
||||
if (text.length() == 0 && bodyPart.isMimeType("text/plain")) {
|
||||
if (text.isEmpty() && bodyPart.isMimeType("text/plain")) {
|
||||
text = bodyText;
|
||||
} else if (html.length() == 0 && bodyPart.isMimeType("text/html")) {
|
||||
} else if (html.isEmpty() && bodyPart.isMimeType("text/html")) {
|
||||
html = bodyText;
|
||||
}
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ public class SettingsImporter {
|
||||
|
||||
// Mark account as disabled if the settings file didn't contain a password
|
||||
boolean createAccountDisabled = (incoming.password == null ||
|
||||
incoming.password.length() == 0);
|
||||
incoming.password.isEmpty());
|
||||
|
||||
if (account.outgoing == null && !WebDavStore.STORE_TYPE.equals(account.incoming.type)) {
|
||||
// All account types except WebDAV need to provide outgoing server settings
|
||||
@ -394,7 +394,7 @@ public class SettingsImporter {
|
||||
putString(editor, accountKeyPrefix + Account.TRANSPORT_URI_KEY, Utility.base64Encode(transportUri));
|
||||
|
||||
// Mark account as disabled if the settings file didn't contain a password
|
||||
if (outgoing.password == null || outgoing.password.length() == 0) {
|
||||
if (outgoing.password == null || outgoing.password.isEmpty()) {
|
||||
createAccountDisabled = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user