Merge "IndexOutOfBoundsException on addPreference in PreferenceGroup"

This commit is contained in:
Alan Viverette
2015-10-07 16:38:02 +00:00
committed by Gerrit Code Review

View File

@@ -148,16 +148,15 @@ public abstract class PreferenceGroup extends Preference implements GenericInfla
}
}
int insertionIndex = Collections.binarySearch(mPreferenceList, preference);
if (insertionIndex < 0) {
insertionIndex = insertionIndex * -1 - 1;
}
if (!onPrepareAddPreference(preference)) {
return false;
}
synchronized(this) {
int insertionIndex = Collections.binarySearch(mPreferenceList, preference);
if (insertionIndex < 0) {
insertionIndex = insertionIndex * -1 - 1;
}
mPreferenceList.add(insertionIndex, preference);
}