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

Merge pull request #89 from andrewgaul/is-empty

Prefer Collection.isEmpty over size
This commit is contained in:
Andrew Chen 2011-11-03 06:34:15 -07:00
commit 64b299ebec
13 changed files with 32 additions and 32 deletions

View File

@ -1135,7 +1135,7 @@ public class Account implements BaseAccount {
ident++;
} while (gotOne);
if (newIdentities.size() == 0) {
if (newIdentities.isEmpty()) {
String name = prefs.getString(mUuid + ".name", null);
String email = prefs.getString(mUuid + ".email", null);
boolean signatureUse = prefs.getBoolean(mUuid + ".signatureUse", true);

View File

@ -154,7 +154,7 @@ public class Preferences {
if (defaultAccount == null) {
Collection<Account> accounts = getAvailableAccounts();
if (accounts.size() > 0) {
if (!accounts.isEmpty()) {
defaultAccount = accounts.iterator().next();
setDefaultAccount(defaultAccount);
}

View File

@ -388,7 +388,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
mAdapter = new AccountsAdapter(newAccounts.toArray(EMPTY_BASE_ACCOUNT_ARRAY));
getListView().setAdapter(mAdapter);
if (newAccounts.size() > 0) {
if (!newAccounts.isEmpty()) {
mHandler.progress(Window.PROGRESS_START);
}
pendingWork.clear();

View File

@ -2567,13 +2567,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
// Read subject from the "subject" parameter.
List<String> subject = uri.getQueryParameters("subject");
if (subject.size() > 0) {
if (!subject.isEmpty()) {
mSubjectView.setText(subject.get(0));
}
// Read message body from the "body" parameter.
List<String> body = uri.getQueryParameters("body");
if (body.size() > 0) {
if (!body.isEmpty()) {
mMessageContentView.setText(body.get(0));
}
}

View File

@ -1977,7 +1977,7 @@ public class MessageList
}
}
if (messagesToSearch.size() > 0) {
if (!messagesToSearch.isEmpty()) {
mController.searchLocalMessages(mAccountUuids, mFolderNames, messagesToSearch.toArray(EMPTY_MESSAGE_ARRAY), mQueryString, mIntegrate, mQueryFlags, mForbiddenFlags,
new MessagingListener() {
@Override
@ -1987,11 +1987,11 @@ public class MessageList
});
}
if (messagesToRemove.size() > 0) {
if (!messagesToRemove.isEmpty()) {
removeMessages(messagesToRemove);
}
if (messagesToAdd.size() > 0) {
if (!messagesToAdd.isEmpty()) {
mHandler.addMessages(messagesToAdd);
}

View File

@ -296,7 +296,7 @@ public class MessagingController implements Runnable {
" Command '" + command.description + "' completed");
for (MessagingListener l : getListeners(command.listener)) {
l.controllerCommandCompleted(mCommands.size() > 0);
l.controllerCommandCompleted(!mCommands.isEmpty());
}
}
} catch (Exception e) {
@ -417,7 +417,7 @@ public class MessagingController implements Runnable {
Folder[] folderArray = localFolders.toArray(EMPTY_FOLDER_ARRAY);
if (refreshRemote || localFolders.size() == 0) {
if (refreshRemote || localFolders.isEmpty()) {
doRefreshRemote(account, listener);
return;
}
@ -1225,7 +1225,7 @@ public class MessagingController implements Runnable {
messages.clear();
final ArrayList<Message> largeMessages = new ArrayList<Message>();
final ArrayList<Message> smallMessages = new ArrayList<Message>();
if (unsyncedMessages.size() > 0) {
if (!unsyncedMessages.isEmpty()) {
/*
* Reverse the order of the messages. Depending on the server this may get us
@ -1481,7 +1481,7 @@ public class MessagingController implements Runnable {
}
});
if (chunk.size() > 0) {
if (!chunk.isEmpty()) {
writeUnsyncedMessages(chunk, localFolder, account, folder);
chunk.clear();
}
@ -2227,7 +2227,7 @@ public class MessagingController implements Runnable {
}
}
if (messages.size() == 0) {
if (messages.isEmpty()) {
return;
}
remoteFolder.setFlags(messages.toArray(EMPTY_MESSAGE_ARRAY), new Flag[] { flag }, newState);
@ -4230,7 +4230,7 @@ public class MessagingController implements Runnable {
names.add(folder.getName());
}
if (names.size() > 0) {
if (!names.isEmpty()) {
PushReceiver receiver = new MessagingControllerPushReceiver(mApplication, account, this);
int maxPushFolders = account.getMaxPushFolders();

View File

@ -176,7 +176,7 @@ public class Apg extends CryptoProvider {
activity.getResources().getString(R.string.insufficient_apg_permissions),
Toast.LENGTH_LONG).show();
}
if (keyIds.size() > 0) {
if (!keyIds.isEmpty()) {
initialKeyIds = new long[keyIds.size()];
for (int i = 0, size = keyIds.size(); i < size; ++i) {
initialKeyIds[i] = keyIds.get(i);

View File

@ -187,8 +187,8 @@ public abstract class Contacts {
*/
public boolean hasContactPicker() {
if (mHasContactPicker == null) {
mHasContactPicker = (mContext.getPackageManager().
queryIntentActivities(contactPickerIntent(), 0).size() > 0);
mHasContactPicker = !(mContext.getPackageManager().
queryIntentActivities(contactPickerIntent(), 0).isEmpty());
}
return mHasContactPicker;
}

View File

@ -78,7 +78,7 @@ public class MimeHeader {
values.add(field.value);
}
}
if (values.size() == 0) {
if (values.isEmpty()) {
return null;
}
return values.toArray(EMPTY_STRING_ARRAY);

View File

@ -73,7 +73,7 @@ public class MimeMultipart extends Multipart {
writer.write(mPreamble + "\r\n");
}
if (mParts.size() == 0) {
if (mParts.isEmpty()) {
writer.write("--" + mBoundary + "\r\n");
}

View File

@ -655,7 +655,7 @@ public class ImapStore extends Store {
if (bracketedObj instanceof ImapList) {
ImapList bracketed = (ImapList)bracketedObj;
if (bracketed.size() > 0) {
if (!bracketed.isEmpty()) {
Object keyObj = bracketed.get(0);
if (keyObj instanceof String) {
String key = (String)keyObj;
@ -1409,7 +1409,7 @@ public class ImapStore extends Store {
// {
// ImapList bracketed = (ImapList)bracketedObj;
//
// if (bracketed.size() > 0)
// if (!bracketed.isEmpty())
// {
// Object keyObj = bracketed.get(0);
// if (keyObj instanceof String)
@ -1545,7 +1545,7 @@ public class ImapStore extends Store {
StringBuilder contentDisposition = new StringBuilder();
if (bodyDisposition != null && bodyDisposition.size() > 0) {
if (bodyDisposition != null && !bodyDisposition.isEmpty()) {
if (!"NIL".equalsIgnoreCase(bodyDisposition.getString(0))) {
contentDisposition.append(bodyDisposition.getString(0).toLowerCase(Locale.US));
}
@ -1817,7 +1817,7 @@ public class ImapStore extends Store {
private List<ImapResponse> receiveCapabilities(List<ImapResponse> responses) {
for (ImapResponse response : responses) {
ImapList capabilityList = null;
if (response.size() > 0 && ImapResponseParser.equalsIgnoreCase(response.get(0), "OK")) {
if (!response.isEmpty() && ImapResponseParser.equalsIgnoreCase(response.get(0), "OK")) {
for (Object thisPart : response) {
if (thisPart instanceof ImapList) {
ImapList thisList = (ImapList)thisPart;
@ -1832,7 +1832,7 @@ public class ImapStore extends Store {
}
if (capabilityList != null) {
if (capabilityList.size() > 0 && ImapResponseParser.equalsIgnoreCase(capabilityList.get(0), CAPABILITY_CAPABILITY)) {
if (!capabilityList.isEmpty() && ImapResponseParser.equalsIgnoreCase(capabilityList.get(0), CAPABILITY_CAPABILITY)) {
if (K9.DEBUG) {
Log.d(K9.LOG_TAG, "Saving " + capabilityList.size() + " capabilities for " + getLogId());
}
@ -2495,13 +2495,13 @@ public class ImapStore extends Store {
ImapMessage message = new ImapMessage("" + uid, ImapFolderPusher.this);
messages.add(message);
}
if (messages.size() > 0) {
if (!messages.isEmpty()) {
pushMessages(messages, true);
}
} else {
List<ImapResponse> untaggedResponses = null;
while (storedUntaggedResponses.size() > 0) {
while (!storedUntaggedResponses.isEmpty()) {
if (K9.DEBUG)
Log.i(K9.LOG_TAG, "Processing " + storedUntaggedResponses.size() + " untagged responses from previous commands for " + getLogId());
untaggedResponses = new ArrayList<ImapResponse>(storedUntaggedResponses);
@ -2608,10 +2608,10 @@ public class ImapStore extends Store {
if (K9.DEBUG)
Log.d(K9.LOG_TAG, "UIDs for messages needing flag sync are " + flagSyncMsgSeqs + " for " + getLogId());
if (flagSyncMsgSeqs.size() > 0) {
if (!flagSyncMsgSeqs.isEmpty()) {
syncMessages(flagSyncMsgSeqs);
}
if (removeMsgUids.size() > 0) {
if (!removeMsgUids.isEmpty()) {
removeMessages(removeMsgUids);
}
}
@ -2649,7 +2649,7 @@ public class ImapStore extends Store {
ImapMessage message = new ImapMessage("" + uid, ImapFolderPusher.this);
messages.add(message);
}
if (messages.size() > 0) {
if (!messages.isEmpty()) {
pushMessages(messages, true);
}
}

View File

@ -892,7 +892,7 @@ public class LocalStore extends Store implements Serializable {
whereClause.append(" )");
}
if (folders != null && folders.size() > 0) {
if (folders != null && !folders.isEmpty()) {
whereClause.append(" AND folder_id in (");
boolean anyAdded = false;
for (LocalFolder folder : folders) {
@ -1786,7 +1786,7 @@ public class LocalStore extends Store implements Serializable {
@Override
public Void doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
Cursor cursor = null;
if (messages.size() == 0) {
if (messages.isEmpty()) {
return null;
}
try {

View File

@ -506,7 +506,7 @@ public class Pop3Store extends Store {
unindexedUids.add(uid);
}
}
if (unindexedUids.size() == 0) {
if (unindexedUids.isEmpty()) {
return;
}
/*