From d38f21265d95f0c5b5d2a78b8c47988a0bb2f98c Mon Sep 17 00:00:00 2001 From: Art O Cathain Date: Sun, 5 Oct 2014 09:40:57 +0100 Subject: [PATCH] use isEmpty instead of size() == 0 for clarify --- src/com/fsck/k9/Preferences.java | 2 +- src/com/fsck/k9/activity/MessageCompose.java | 2 +- src/com/fsck/k9/cache/EmailProviderCache.java | 4 ++-- src/com/fsck/k9/cache/EmailProviderCacheCursor.java | 4 ++-- src/com/fsck/k9/fragment/MessageListFragment.java | 10 +++++----- src/com/fsck/k9/helper/Contacts.java | 2 +- src/com/fsck/k9/mail/store/ImapStore.java | 10 +++++----- src/com/fsck/k9/mail/store/Pop3Store.java | 2 +- src/com/fsck/k9/mail/store/WebDavStore.java | 6 +++--- src/com/fsck/k9/preferences/Settings.java | 2 +- src/com/fsck/k9/preferences/Storage.java | 4 ++-- src/com/fsck/k9/search/LocalSearch.java | 4 ++-- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/com/fsck/k9/Preferences.java b/src/com/fsck/k9/Preferences.java index c5d9b9a37..5fd4929a3 100644 --- a/src/com/fsck/k9/Preferences.java +++ b/src/com/fsck/k9/Preferences.java @@ -39,7 +39,7 @@ public class Preferences { private Preferences(Context context) { mStorage = Storage.getStorage(context); mContext = context; - if (mStorage.size() == 0) { + if (mStorage.isEmpty()) { Log.i(K9.LOG_TAG, "Preferences storage is zero-size, importing from Android-style preferences"); Editor editor = mStorage.edit(); editor.copy(context.getSharedPreferences("AndroidMail.Main", Context.MODE_PRIVATE)); diff --git a/src/com/fsck/k9/activity/MessageCompose.java b/src/com/fsck/k9/activity/MessageCompose.java index a1dbf2873..8110f66e9 100644 --- a/src/com/fsck/k9/activity/MessageCompose.java +++ b/src/com/fsck/k9/activity/MessageCompose.java @@ -1056,7 +1056,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, } private boolean addRecipients(TextView view, List recipients) { - if (recipients == null || recipients.size() == 0) { + if (recipients == null || recipients.isEmpty()) { return false; } diff --git a/src/com/fsck/k9/cache/EmailProviderCache.java b/src/com/fsck/k9/cache/EmailProviderCache.java index 1cdf70103..9b3e7d5e0 100644 --- a/src/com/fsck/k9/cache/EmailProviderCache.java +++ b/src/com/fsck/k9/cache/EmailProviderCache.java @@ -101,7 +101,7 @@ public class EmailProviderCache { Map map = mMessageCache.get(messageId); if (map != null) { map.remove(columnName); - if (map.size() == 0) { + if (map.isEmpty()) { mMessageCache.remove(messageId); } } @@ -115,7 +115,7 @@ public class EmailProviderCache { Map map = mThreadCache.get(threadRootId); if (map != null) { map.remove(columnName); - if (map.size() == 0) { + if (map.isEmpty()) { mThreadCache.remove(threadRootId); } } diff --git a/src/com/fsck/k9/cache/EmailProviderCacheCursor.java b/src/com/fsck/k9/cache/EmailProviderCacheCursor.java index aeb4bdf13..fdf75993a 100644 --- a/src/com/fsck/k9/cache/EmailProviderCacheCursor.java +++ b/src/com/fsck/k9/cache/EmailProviderCacheCursor.java @@ -108,7 +108,7 @@ public class EmailProviderCacheCursor extends CursorWrapper { @Override public boolean moveToPosition(int position) { - if (mHiddenRows.size() == 0) { + if (mHiddenRows.isEmpty()) { return super.moveToPosition(position); } @@ -126,7 +126,7 @@ public class EmailProviderCacheCursor extends CursorWrapper { @Override public int getPosition() { - if (mHiddenRows.size() == 0) { + if (mHiddenRows.isEmpty()) { return super.getPosition(); } diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index c8dd39d73..f6bd09f74 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -1814,7 +1814,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener } List folderNames = mSearch.getFolderNames(); - return (folderNames.size() == 0 || folderNames.contains(folder)); + return (folderNames.isEmpty() || folderNames.contains(folder)); } } @@ -2362,7 +2362,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener } private void setFlagForSelected(final Flag flag, final boolean newState) { - if (mSelected.size() == 0) { + if (mSelected.isEmpty()) { return; } @@ -2586,7 +2586,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener private boolean checkCopyOrMovePossible(final List messages, final FolderOperation operation) { - if (messages.size() == 0) { + if (messages.isEmpty()) { return false; } @@ -3515,7 +3515,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener } private void cleanupSelected(Cursor cursor) { - if (mSelected.size() == 0) { + if (mSelected.isEmpty()) { return; } @@ -3534,7 +3534,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener * Starts or finishes the action mode when necessary. */ private void resetActionMode() { - if (mSelected.size() == 0) { + if (mSelected.isEmpty()) { if (mActionMode != null) { mActionMode.finish(); } diff --git a/src/com/fsck/k9/helper/Contacts.java b/src/com/fsck/k9/helper/Contacts.java index 75c084aba..022139f89 100644 --- a/src/com/fsck/k9/helper/Contacts.java +++ b/src/com/fsck/k9/helper/Contacts.java @@ -302,7 +302,7 @@ public class Contacts { } // Return 'null' if no email addresses have been found - if (email.size() == 0) { + if (email.isEmpty()) { return null; } diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index 038f17084..f166d291a 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -1097,7 +1097,7 @@ public class ImapStore extends Store { throw new MessagingException("ImapFolder.copyMessages passed non-ImapFolder"); } - if (messages.size() == 0) { + if (messages.isEmpty()) { return null; } @@ -1193,7 +1193,7 @@ public class ImapStore extends Store { @Override public Map moveMessages(List messages, Folder folder) throws MessagingException { - if (messages.size() == 0) + if (messages.isEmpty()) return null; Map uidMap = copyMessages(messages, folder); setFlags(messages, Collections.singleton(Flag.DELETED), true); @@ -1202,7 +1202,7 @@ public class ImapStore extends Store { @Override public void delete(List messages, String trashFolderName) throws MessagingException { - if (messages.size() == 0) + if (messages.isEmpty()) return; if (trashFolderName == null || getName().equalsIgnoreCase(trashFolderName)) { @@ -1435,7 +1435,7 @@ public class ImapStore extends Store { @Override public void fetch(List messages, FetchProfile fp, MessageRetrievalListener listener) throws MessagingException { - if (messages == null || messages.size() == 0) { + if (messages == null || messages.isEmpty()) { return; } checkOpen(); //only need READ access @@ -2036,7 +2036,7 @@ public class ImapStore extends Store { * with the behavior of other similar methods (copyMessages, moveMessages) which * return null. */ - return (uidMap.size() == 0) ? null : uidMap; + return (uidMap.isEmpty()) ? null : uidMap; } catch (IOException ioe) { throw ioExceptionHandler(mConnection, ioe); } diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index 031023563..0a2ca179a 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -763,7 +763,7 @@ public class Pop3Store extends Store { @Override public void fetch(List messages, FetchProfile fp, MessageRetrievalListener listener) throws MessagingException { - if (messages == null || messages.size() == 0) { + if (messages == null || messages.isEmpty()) { return; } List uids = new ArrayList(); diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index 85351a1f9..a58a82779 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -1501,7 +1501,7 @@ public class WebDavStore extends Store { public void fetch(List messages, FetchProfile fp, MessageRetrievalListener listener) throws MessagingException { if (messages == null || - messages.size() == 0) { + messages.isEmpty()) { return; } @@ -1654,7 +1654,7 @@ public class WebDavStore extends Store { String[] uids; if (startMessages == null || - startMessages.size() == 0) { + startMessages.isEmpty()) { return; } @@ -1724,7 +1724,7 @@ public class WebDavStore extends Store { List messages = new ArrayList(10); if (startMessages == null || - startMessages.size() == 0) { + startMessages.isEmpty()) { return; } diff --git a/src/com/fsck/k9/preferences/Settings.java b/src/com/fsck/k9/preferences/Settings.java index 1d06b7fd2..63e41225d 100644 --- a/src/com/fsck/k9/preferences/Settings.java +++ b/src/com/fsck/k9/preferences/Settings.java @@ -51,7 +51,7 @@ public class Settings { SortedMap headMap = versions.headMap(version + 1); // Skip this setting if it was introduced after 'version' - if (headMap.size() == 0) { + if (headMap.isEmpty()) { continue; } diff --git a/src/com/fsck/k9/preferences/Storage.java b/src/com/fsck/k9/preferences/Storage.java index f4c4c4d0e..88260f7ff 100644 --- a/src/com/fsck/k9/preferences/Storage.java +++ b/src/com/fsck/k9/preferences/Storage.java @@ -290,8 +290,8 @@ public class Storage implements SharedPreferences { } } - public long size() { - return storage.size(); + public boolean isEmpty() { + return storage.isEmpty(); } //@Override diff --git a/src/com/fsck/k9/search/LocalSearch.java b/src/com/fsck/k9/search/LocalSearch.java index 68dddbf89..abff83163 100644 --- a/src/com/fsck/k9/search/LocalSearch.java +++ b/src/com/fsck/k9/search/LocalSearch.java @@ -328,7 +328,7 @@ public class LocalSearch implements SearchSpecification { */ @Override public String[] getAccountUuids() { - if (mAccountUuids.size() == 0) { + if (mAccountUuids.isEmpty()) { return new String[] { SearchSpecification.ALL_ACCOUNTS }; } @@ -343,7 +343,7 @@ public class LocalSearch implements SearchSpecification { * @return {@code true} if all accounts should be searched. */ public boolean searchAllAccounts() { - return (mAccountUuids.size() == 0); + return (mAccountUuids.isEmpty()); } /**