Skip to content

Commit 569f1bf

Browse files
committed
Merge pull request #130 from omerjerk/master
preferredAbi should be a HashMap instead of an Array
2 parents c64c971 + a6931e8 commit 569f1bf

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/processing/mode/android/AVD.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
import java.io.IOException;
99
import java.util.ArrayList;
10+
import java.util.HashMap;
11+
import java.util.List;
12+
import java.util.Map;
1013

1114

1215
public class AVD {
@@ -48,8 +51,8 @@ public class AVD {
4851
static ArrayList<String> badList;
4952
// static ArrayList<String> skinList;
5053

51-
private String[] preferredAbi = new String[50];
52-
private static ArrayList<String> abiList = new ArrayList<>();
54+
private Map<String, String> preferredAbi = new HashMap<>(30);
55+
private static List<String> abiList = new ArrayList<>();
5356

5457
/** Default virtual device used by Processing. */
5558
static public final AVD defaultAVD =
@@ -66,6 +69,7 @@ public AVD(final String name, final String target) {
6669

6770
private void initializeAbiList() {
6871
if (abiList.size() == 0) {
72+
//The order in this list determines the preference of one abi over the other
6973
abiList.add("armeabi");
7074
abiList.add("x86");
7175
abiList.add("x86_64");
@@ -165,11 +169,10 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
165169
abi = m[1];
166170

167171
if (api != null && abi != null) {
168-
int index = Integer.parseInt(api);
169-
if (preferredAbi[index] == null) {
170-
preferredAbi[index] = abi;
171-
} else if (abiList.indexOf(preferredAbi[index]) < abiList.indexOf(abi)) {
172-
preferredAbi[index] = abi;
172+
if (preferredAbi.get(api) == null) {
173+
preferredAbi.put(api, abi);
174+
} else if (abiList.indexOf(preferredAbi.get(api)) < abiList.indexOf(abi)) {
175+
preferredAbi.put(api, abi);
173176
}
174177
api = null;
175178
abi = null;
@@ -178,7 +181,7 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
178181
}
179182
} catch (InterruptedException e) {}
180183

181-
if (preferredAbi[Integer.parseInt(AndroidBuild.sdkVersion)] == null) {
184+
if (preferredAbi.get(AndroidBuild.sdkVersion) == null) {
182185
return false;
183186
}
184187

@@ -189,7 +192,7 @@ protected boolean create(final AndroidSDK sdk) throws IOException {
189192
"-t", target,
190193
"-c", DEFAULT_SDCARD_SIZE,
191194
"-s", DEFAULT_SKIN,
192-
"--abi", preferredAbi[Integer.parseInt(AndroidBuild.sdkVersion)]
195+
"--abi", preferredAbi.get(AndroidBuild.sdkVersion)
193196
};
194197

195198
// Set the list to null so that exists() will check again

0 commit comments

Comments
 (0)