diff --git a/core/java/android/preference/PreferenceGroup.java b/core/java/android/preference/PreferenceGroup.java index 5e84086531450..f17506b98a2b1 100644 --- a/core/java/android/preference/PreferenceGroup.java +++ b/core/java/android/preference/PreferenceGroup.java @@ -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); }