Merge "Do not register null pointers as dictionaries"

main
Jean Chalard 2011-07-21 22:56:46 -07:00 committed by Android (Google) Code Review
commit 6988d09ac2
1 changed files with 4 additions and 1 deletions

View File

@ -17,6 +17,7 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
@ -36,11 +37,13 @@ public class DictionaryCollection extends Dictionary {
mDictionaries = new CopyOnWriteArrayList<Dictionary>(); mDictionaries = new CopyOnWriteArrayList<Dictionary>();
} else { } else {
mDictionaries = new CopyOnWriteArrayList<Dictionary>(dictionaries); mDictionaries = new CopyOnWriteArrayList<Dictionary>(dictionaries);
mDictionaries.removeAll(Collections.singleton(null));
} }
} }
public DictionaryCollection(Collection<Dictionary> dictionaries) { public DictionaryCollection(Collection<Dictionary> dictionaries) {
mDictionaries = new CopyOnWriteArrayList<Dictionary>(dictionaries); mDictionaries = new CopyOnWriteArrayList<Dictionary>(dictionaries);
mDictionaries.removeAll(Collections.singleton(null));
} }
@Override @Override
@ -70,6 +73,6 @@ public class DictionaryCollection extends Dictionary {
} }
public void addDictionary(Dictionary newDict) { public void addDictionary(Dictionary newDict) {
mDictionaries.add(newDict); if (null != newDict) mDictionaries.add(newDict);
} }
} }