1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

use isEmpty instead of size() == 0 for clarify

This commit is contained in:
Art O Cathain 2014-10-05 09:40:57 +01:00
parent 02c0b5f2a3
commit d38f21265d
12 changed files with 26 additions and 26 deletions

View File

@ -39,7 +39,7 @@ public class Preferences {
private Preferences(Context context) { private Preferences(Context context) {
mStorage = Storage.getStorage(context); mStorage = Storage.getStorage(context);
mContext = 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"); Log.i(K9.LOG_TAG, "Preferences storage is zero-size, importing from Android-style preferences");
Editor editor = mStorage.edit(); Editor editor = mStorage.edit();
editor.copy(context.getSharedPreferences("AndroidMail.Main", Context.MODE_PRIVATE)); editor.copy(context.getSharedPreferences("AndroidMail.Main", Context.MODE_PRIVATE));

View File

@ -1056,7 +1056,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
} }
private boolean addRecipients(TextView view, List<String> recipients) { private boolean addRecipients(TextView view, List<String> recipients) {
if (recipients == null || recipients.size() == 0) { if (recipients == null || recipients.isEmpty()) {
return false; return false;
} }

View File

@ -101,7 +101,7 @@ public class EmailProviderCache {
Map<String, String> map = mMessageCache.get(messageId); Map<String, String> map = mMessageCache.get(messageId);
if (map != null) { if (map != null) {
map.remove(columnName); map.remove(columnName);
if (map.size() == 0) { if (map.isEmpty()) {
mMessageCache.remove(messageId); mMessageCache.remove(messageId);
} }
} }
@ -115,7 +115,7 @@ public class EmailProviderCache {
Map<String, String> map = mThreadCache.get(threadRootId); Map<String, String> map = mThreadCache.get(threadRootId);
if (map != null) { if (map != null) {
map.remove(columnName); map.remove(columnName);
if (map.size() == 0) { if (map.isEmpty()) {
mThreadCache.remove(threadRootId); mThreadCache.remove(threadRootId);
} }
} }

View File

@ -108,7 +108,7 @@ public class EmailProviderCacheCursor extends CursorWrapper {
@Override @Override
public boolean moveToPosition(int position) { public boolean moveToPosition(int position) {
if (mHiddenRows.size() == 0) { if (mHiddenRows.isEmpty()) {
return super.moveToPosition(position); return super.moveToPosition(position);
} }
@ -126,7 +126,7 @@ public class EmailProviderCacheCursor extends CursorWrapper {
@Override @Override
public int getPosition() { public int getPosition() {
if (mHiddenRows.size() == 0) { if (mHiddenRows.isEmpty()) {
return super.getPosition(); return super.getPosition();
} }

View File

@ -1814,7 +1814,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
} }
List<String> folderNames = mSearch.getFolderNames(); List<String> 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) { private void setFlagForSelected(final Flag flag, final boolean newState) {
if (mSelected.size() == 0) { if (mSelected.isEmpty()) {
return; return;
} }
@ -2586,7 +2586,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
private boolean checkCopyOrMovePossible(final List<Message> messages, private boolean checkCopyOrMovePossible(final List<Message> messages,
final FolderOperation operation) { final FolderOperation operation) {
if (messages.size() == 0) { if (messages.isEmpty()) {
return false; return false;
} }
@ -3515,7 +3515,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
} }
private void cleanupSelected(Cursor cursor) { private void cleanupSelected(Cursor cursor) {
if (mSelected.size() == 0) { if (mSelected.isEmpty()) {
return; return;
} }
@ -3534,7 +3534,7 @@ public class MessageListFragment extends Fragment implements OnItemClickListener
* Starts or finishes the action mode when necessary. * Starts or finishes the action mode when necessary.
*/ */
private void resetActionMode() { private void resetActionMode() {
if (mSelected.size() == 0) { if (mSelected.isEmpty()) {
if (mActionMode != null) { if (mActionMode != null) {
mActionMode.finish(); mActionMode.finish();
} }

View File

@ -302,7 +302,7 @@ public class Contacts {
} }
// Return 'null' if no email addresses have been found // Return 'null' if no email addresses have been found
if (email.size() == 0) { if (email.isEmpty()) {
return null; return null;
} }

View File

@ -1097,7 +1097,7 @@ public class ImapStore extends Store {
throw new MessagingException("ImapFolder.copyMessages passed non-ImapFolder"); throw new MessagingException("ImapFolder.copyMessages passed non-ImapFolder");
} }
if (messages.size() == 0) { if (messages.isEmpty()) {
return null; return null;
} }
@ -1193,7 +1193,7 @@ public class ImapStore extends Store {
@Override @Override
public Map<String, String> moveMessages(List<? extends Message> messages, Folder folder) throws MessagingException { public Map<String, String> moveMessages(List<? extends Message> messages, Folder folder) throws MessagingException {
if (messages.size() == 0) if (messages.isEmpty())
return null; return null;
Map<String, String> uidMap = copyMessages(messages, folder); Map<String, String> uidMap = copyMessages(messages, folder);
setFlags(messages, Collections.singleton(Flag.DELETED), true); setFlags(messages, Collections.singleton(Flag.DELETED), true);
@ -1202,7 +1202,7 @@ public class ImapStore extends Store {
@Override @Override
public void delete(List<? extends Message> messages, String trashFolderName) throws MessagingException { public void delete(List<? extends Message> messages, String trashFolderName) throws MessagingException {
if (messages.size() == 0) if (messages.isEmpty())
return; return;
if (trashFolderName == null || getName().equalsIgnoreCase(trashFolderName)) { if (trashFolderName == null || getName().equalsIgnoreCase(trashFolderName)) {
@ -1435,7 +1435,7 @@ public class ImapStore extends Store {
@Override @Override
public void fetch(List<? extends Message> messages, FetchProfile fp, MessageRetrievalListener listener) public void fetch(List<? extends Message> messages, FetchProfile fp, MessageRetrievalListener listener)
throws MessagingException { throws MessagingException {
if (messages == null || messages.size() == 0) { if (messages == null || messages.isEmpty()) {
return; return;
} }
checkOpen(); //only need READ access checkOpen(); //only need READ access
@ -2036,7 +2036,7 @@ public class ImapStore extends Store {
* with the behavior of other similar methods (copyMessages, moveMessages) which * with the behavior of other similar methods (copyMessages, moveMessages) which
* return null. * return null.
*/ */
return (uidMap.size() == 0) ? null : uidMap; return (uidMap.isEmpty()) ? null : uidMap;
} catch (IOException ioe) { } catch (IOException ioe) {
throw ioExceptionHandler(mConnection, ioe); throw ioExceptionHandler(mConnection, ioe);
} }

View File

@ -763,7 +763,7 @@ public class Pop3Store extends Store {
@Override @Override
public void fetch(List<? extends Message> messages, FetchProfile fp, MessageRetrievalListener listener) public void fetch(List<? extends Message> messages, FetchProfile fp, MessageRetrievalListener listener)
throws MessagingException { throws MessagingException {
if (messages == null || messages.size() == 0) { if (messages == null || messages.isEmpty()) {
return; return;
} }
List<String> uids = new ArrayList<String>(); List<String> uids = new ArrayList<String>();

View File

@ -1501,7 +1501,7 @@ public class WebDavStore extends Store {
public void fetch(List<? extends Message> messages, FetchProfile fp, MessageRetrievalListener listener) public void fetch(List<? extends Message> messages, FetchProfile fp, MessageRetrievalListener listener)
throws MessagingException { throws MessagingException {
if (messages == null || if (messages == null ||
messages.size() == 0) { messages.isEmpty()) {
return; return;
} }
@ -1654,7 +1654,7 @@ public class WebDavStore extends Store {
String[] uids; String[] uids;
if (startMessages == null || if (startMessages == null ||
startMessages.size() == 0) { startMessages.isEmpty()) {
return; return;
} }
@ -1724,7 +1724,7 @@ public class WebDavStore extends Store {
List<Message> messages = new ArrayList<Message>(10); List<Message> messages = new ArrayList<Message>(10);
if (startMessages == null || if (startMessages == null ||
startMessages.size() == 0) { startMessages.isEmpty()) {
return; return;
} }

View File

@ -51,7 +51,7 @@ public class Settings {
SortedMap<Integer, SettingsDescription> headMap = versions.headMap(version + 1); SortedMap<Integer, SettingsDescription> headMap = versions.headMap(version + 1);
// Skip this setting if it was introduced after 'version' // Skip this setting if it was introduced after 'version'
if (headMap.size() == 0) { if (headMap.isEmpty()) {
continue; continue;
} }

View File

@ -290,8 +290,8 @@ public class Storage implements SharedPreferences {
} }
} }
public long size() { public boolean isEmpty() {
return storage.size(); return storage.isEmpty();
} }
//@Override //@Override

View File

@ -328,7 +328,7 @@ public class LocalSearch implements SearchSpecification {
*/ */
@Override @Override
public String[] getAccountUuids() { public String[] getAccountUuids() {
if (mAccountUuids.size() == 0) { if (mAccountUuids.isEmpty()) {
return new String[] { SearchSpecification.ALL_ACCOUNTS }; return new String[] { SearchSpecification.ALL_ACCOUNTS };
} }
@ -343,7 +343,7 @@ public class LocalSearch implements SearchSpecification {
* @return {@code true} if all accounts should be searched. * @return {@code true} if all accounts should be searched.
*/ */
public boolean searchAllAccounts() { public boolean searchAllAccounts() {
return (mAccountUuids.size() == 0); return (mAccountUuids.isEmpty());
} }
/** /**