Skip to content
Snippets Groups Projects
Commit 0dc422e0 authored by Jean Chalard's avatar Jean Chalard
Browse files

Use an iterator to remove stuff from an ArrayList.

Silly me >.>

Bug: 9306154
Change-Id: Ic00e9d6a31cd1d7aacefe68b7be9c2199e297b0d
parent 0bfc2bc4
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ import com.android.inputmethod.latin.makedict.UnsupportedFormatException; ...@@ -30,6 +30,7 @@ import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.Locale; import java.util.Locale;
/** /**
...@@ -301,12 +302,14 @@ public class DictionaryInfoUtils { ...@@ -301,12 +302,14 @@ public class DictionaryInfoUtils {
private static void addOrUpdateDictInfo(final ArrayList<DictionaryInfo> dictList, private static void addOrUpdateDictInfo(final ArrayList<DictionaryInfo> dictList,
final DictionaryInfo newElement) { final DictionaryInfo newElement) {
for (final DictionaryInfo info : dictList) { final Iterator<DictionaryInfo> iter = dictList.iterator();
if (info.mLocale.equals(newElement.mLocale)) { while (iter.hasNext()) {
if (newElement.mVersion <= info.mVersion) { final DictionaryInfo thisDictInfo = iter.next();
if (thisDictInfo.mLocale.equals(newElement.mLocale)) {
if (newElement.mVersion <= thisDictInfo.mVersion) {
return; return;
} }
dictList.remove(info); iter.remove();
} }
} }
dictList.add(newElement); dictList.add(newElement);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment