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

use Set instead of implementation type

This commit is contained in:
András Veres-Szentkirályi 2014-02-15 23:48:35 +01:00
parent cbbd0bc405
commit ab3044c9fa
7 changed files with 17 additions and 14 deletions

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -168,7 +169,7 @@ public class Prefs extends K9PreferenceActivity {
List<CharSequence> entryVector = new ArrayList<CharSequence>(Arrays.asList(mLanguage.getEntries())); List<CharSequence> entryVector = new ArrayList<CharSequence>(Arrays.asList(mLanguage.getEntries()));
List<CharSequence> entryValueVector = new ArrayList<CharSequence>(Arrays.asList(mLanguage.getEntryValues())); List<CharSequence> entryValueVector = new ArrayList<CharSequence>(Arrays.asList(mLanguage.getEntryValues()));
String supportedLanguages[] = getResources().getStringArray(R.array.supported_languages); String supportedLanguages[] = getResources().getStringArray(R.array.supported_languages);
HashSet<String> supportedLanguageSet = new HashSet<String>(Arrays.asList(supportedLanguages)); Set<String> supportedLanguageSet = new HashSet<String>(Arrays.asList(supportedLanguages));
for (int i = entryVector.size() - 1; i > -1; --i) { for (int i = entryVector.size() - 1; i > -1; --i) {
if (!supportedLanguageSet.contains(entryValueVector.get(i))) { if (!supportedLanguageSet.contains(entryValueVector.get(i))) {
entryVector.remove(i); entryVector.remove(i);

View File

@ -616,11 +616,11 @@ public class MessagingController implements Runnable {
List <? extends Folder > remoteFolders = store.getPersonalNamespaces(false); List <? extends Folder > remoteFolders = store.getPersonalNamespaces(false);
LocalStore localStore = account.getLocalStore(); LocalStore localStore = account.getLocalStore();
HashSet<String> remoteFolderNames = new HashSet<String>(); Set<String> remoteFolderNames = new HashSet<String>();
List<LocalFolder> foldersToCreate = new LinkedList<LocalFolder>(); List<LocalFolder> foldersToCreate = new LinkedList<LocalFolder>();
localFolders = localStore.getPersonalNamespaces(false); localFolders = localStore.getPersonalNamespaces(false);
HashSet<String> localFolderNames = new HashSet<String>(); Set<String> localFolderNames = new HashSet<String>();
for (Folder localFolder : localFolders) { for (Folder localFolder : localFolders) {
localFolderNames.add(localFolder.getName()); localFolderNames.add(localFolder.getName());
} }
@ -693,7 +693,7 @@ public class MessagingController implements Runnable {
public void searchLocalMessagesSynchronous(final LocalSearch search, final MessagingListener listener) { public void searchLocalMessagesSynchronous(final LocalSearch search, final MessagingListener listener) {
final AccountStats stats = new AccountStats(); final AccountStats stats = new AccountStats();
final HashSet<String> uuidSet = new HashSet<String>(Arrays.asList(search.getAccountUuids())); final Set<String> uuidSet = new HashSet<String>(Arrays.asList(search.getAccountUuids()));
Account[] accounts = Preferences.getPreferences(mApplication.getApplicationContext()).getAccounts(); Account[] accounts = Preferences.getPreferences(mApplication.getApplicationContext()).getAccounts();
boolean allAccounts = uuidSet.contains(SearchSpecification.ALL_ACCOUNTS); boolean allAccounts = uuidSet.contains(SearchSpecification.ALL_ACCOUNTS);

View File

@ -26,7 +26,7 @@ public abstract class Message implements Part, CompositeBody {
protected String mUid; protected String mUid;
protected HashSet<Flag> mFlags = new HashSet<Flag>(); protected Set<Flag> mFlags = new HashSet<Flag>();
protected Date mInternalDate; protected Date mInternalDate;

View File

@ -531,7 +531,7 @@ public class ImapStore extends Store {
return allFolders; return allFolders;
} else { } else {
List<Folder> resultFolders = new LinkedList<Folder>(); List<Folder> resultFolders = new LinkedList<Folder>();
HashSet<String> subscribedFolderNames = new HashSet<String>(); Set<String> subscribedFolderNames = new HashSet<String>();
List <? extends Folder > subscribedFolders = listFolders(connection, true); List <? extends Folder > subscribedFolders = listFolders(connection, true);
for (Folder subscribedFolder : subscribedFolders) { for (Folder subscribedFolder : subscribedFolders) {
subscribedFolderNames.add(subscribedFolder.getName()); subscribedFolderNames.add(subscribedFolder.getName());
@ -1488,7 +1488,7 @@ public class ImapStore extends Store {
* Envelope - UID FETCH ([FLAGS] INTERNALDATE UID RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (date subject from content-type to cc)]) * Envelope - UID FETCH ([FLAGS] INTERNALDATE UID RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (date subject from content-type to cc)])
* *
*/ */
LinkedHashSet<String> fetchFields = new LinkedHashSet<String>(); Set<String> fetchFields = new LinkedHashSet<String>();
fetchFields.add("UID"); fetchFields.add("UID");
if (fp.contains(FetchProfile.Item.FLAGS)) { if (fp.contains(FetchProfile.Item.FLAGS)) {
fetchFields.add("FLAGS"); fetchFields.add("FLAGS");

View File

@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class Pop3Store extends Store { public class Pop3Store extends Store {
public static final String STORE_TYPE = "POP3"; public static final String STORE_TYPE = "POP3";
@ -628,7 +629,7 @@ public class Pop3Store extends Store {
private void indexUids(ArrayList<String> uids) private void indexUids(ArrayList<String> uids)
throws MessagingException, IOException { throws MessagingException, IOException {
HashSet<String> unindexedUids = new HashSet<String>(); Set<String> unindexedUids = new HashSet<String>();
for (String uid : uids) { for (String uid : uids) {
if (mUidToMsgMap.get(uid) == null) { if (mUidToMsgMap.get(uid) == null) {
if (K9.DEBUG && K9.DEBUG_PROTOCOL_POP3) { if (K9.DEBUG && K9.DEBUG_PROTOCOL_POP3) {
@ -801,7 +802,7 @@ public class Pop3Store extends Store {
} }
} }
} else { } else {
HashSet<String> msgUidIndex = new HashSet<String>(); Set<String> msgUidIndex = new HashSet<String>();
for (Message message : messages) { for (Message message : messages) {
msgUidIndex.add(message.getUid()); msgUidIndex.add(message.getUid());
} }

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Stack; import java.util.Stack;
import java.util.Set;
import android.database.Cursor; import android.database.Cursor;
import android.os.Parcel; import android.os.Parcel;
@ -243,8 +244,8 @@ public class ConditionsTreeNode implements Parcelable {
* Get a set of all the leaves in the tree. * Get a set of all the leaves in the tree.
* @return Set of all the leaves. * @return Set of all the leaves.
*/ */
public HashSet<ConditionsTreeNode> getLeafSet() { public Set<ConditionsTreeNode> getLeafSet() {
HashSet<ConditionsTreeNode> leafSet = new HashSet<ConditionsTreeNode>(); Set<ConditionsTreeNode> leafSet = new HashSet<ConditionsTreeNode>();
return getLeafSet(leafSet); return getLeafSet(leafSet);
} }
@ -338,7 +339,7 @@ public class ConditionsTreeNode implements Parcelable {
* @param leafSet Leafset that's being built. * @param leafSet Leafset that's being built.
* @return Set of leaves being completed. * @return Set of leaves being completed.
*/ */
private HashSet<ConditionsTreeNode> getLeafSet(HashSet<ConditionsTreeNode> leafSet) { private Set<ConditionsTreeNode> getLeafSet(Set<ConditionsTreeNode> leafSet) {
if (mLeft == null && mRight == null) { if (mLeft == null && mRight == null) {
// if we ended up in a leaf, add ourself and return // if we ended up in a leaf, add ourself and return
leafSet.add(this); leafSet.add(this);

View File

@ -28,9 +28,9 @@ public class LocalSearch implements SearchSpecification {
private boolean mManualSearch = false; private boolean mManualSearch = false;
// since the uuid isn't in the message table it's not in the tree neither // since the uuid isn't in the message table it's not in the tree neither
private HashSet<String> mAccountUuids = new HashSet<String>(); private Set<String> mAccountUuids = new HashSet<String>();
private ConditionsTreeNode mConditions = null; private ConditionsTreeNode mConditions = null;
private HashSet<ConditionsTreeNode> mLeafSet = new HashSet<ConditionsTreeNode>(); private Set<ConditionsTreeNode> mLeafSet = new HashSet<ConditionsTreeNode>();
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////