Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge "IndexOutOfBoundsException on addPreference in PreferenceGroup"
Browse files Browse the repository at this point in the history
  • Loading branch information
alanv authored and Gerrit Code Review committed Oct 7, 2015
2 parents f8ac5c3 + 6689c90 commit f518ad0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions core/java/android/preference/PreferenceGroup.java
Expand Up @@ -148,16 +148,15 @@ public boolean addPreference(Preference preference) {
}
}

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);
}

Expand Down

0 comments on commit f518ad0

Please sign in to comment.