Revert "Add Preference#onDetachedFromActivity"

This reverts commit e18dc50c63.
Fixes: 27807793

Change-Id: Ib0384e3deb8d6376265e8e60f14490de128c9b68
(cherry picked from commit eff3ca5480)
This commit is contained in:
Jason Monk
2016-04-04 13:19:31 +00:00
parent 691b1a6005
commit b65b7105cd
5 changed files with 9 additions and 39 deletions

View File

@@ -29701,7 +29701,6 @@ package android.preference {
method protected void onClick(); method protected void onClick();
method protected android.view.View onCreateView(android.view.ViewGroup); method protected android.view.View onCreateView(android.view.ViewGroup);
method public void onDependencyChanged(android.preference.Preference, boolean); method public void onDependencyChanged(android.preference.Preference, boolean);
method protected void onDetachedFromActivity();
method protected java.lang.Object onGetDefaultValue(android.content.res.TypedArray, int); method protected java.lang.Object onGetDefaultValue(android.content.res.TypedArray, int);
method public void onParentChanged(android.preference.Preference, boolean); method public void onParentChanged(android.preference.Preference, boolean);
method protected void onPrepareForRemoval(); method protected void onPrepareForRemoval();

View File

@@ -32005,7 +32005,6 @@ package android.preference {
method protected void onClick(); method protected void onClick();
method protected android.view.View onCreateView(android.view.ViewGroup); method protected android.view.View onCreateView(android.view.ViewGroup);
method public void onDependencyChanged(android.preference.Preference, boolean); method public void onDependencyChanged(android.preference.Preference, boolean);
method protected void onDetachedFromActivity();
method protected java.lang.Object onGetDefaultValue(android.content.res.TypedArray, int); method protected java.lang.Object onGetDefaultValue(android.content.res.TypedArray, int);
method public void onParentChanged(android.preference.Preference, boolean); method public void onParentChanged(android.preference.Preference, boolean);
method protected void onPrepareForRemoval(); method protected void onPrepareForRemoval();

View File

@@ -1184,10 +1184,9 @@ public class Preference implements Comparable<Preference> {
/** /**
* Called when the Preference hierarchy has been attached to the * Called when the Preference hierarchy has been attached to the
* {@link PreferenceActivity} or {@link PreferenceFragment}. This can * {@link PreferenceActivity}. This can also be called when this
* also be called when this Preference has been attached to a group * Preference has been attached to a group that was already attached
* that was already attached to the {@link PreferenceActivity} or * to the {@link PreferenceActivity}.
* {@link PreferenceFragment}.
*/ */
protected void onAttachedToActivity() { protected void onAttachedToActivity() {
// At this point, the hierarchy that this preference is in is connected // At this point, the hierarchy that this preference is in is connected
@@ -1195,16 +1194,6 @@ public class Preference implements Comparable<Preference> {
registerDependency(); registerDependency();
} }
/**
* Called when the Preference hierarchy has been detached from the
* {@link PreferenceActivity} or {@link PreferenceFragment}. This can
* also be called when this Preference has been removed from a group
* that was already attached to the {@link PreferenceActivity} or
* {@link PreferenceFragment}.
*/
protected void onDetachedFromActivity() {
}
private void registerDependency() { private void registerDependency() {
if (TextUtils.isEmpty(mDependencyKey)) return; if (TextUtils.isEmpty(mDependencyKey)) return;

View File

@@ -186,11 +186,7 @@ public abstract class PreferenceGroup extends Preference implements GenericInfla
private boolean removePreferenceInt(Preference preference) { private boolean removePreferenceInt(Preference preference) {
synchronized(this) { synchronized(this) {
preference.onPrepareForRemoval(); preference.onPrepareForRemoval();
boolean success = mPreferenceList.remove(preference); return mPreferenceList.remove(preference);
if (mAttachedToActivity) {
preference.onDetachedFromActivity();
}
return success;
} }
} }
@@ -266,7 +262,7 @@ public abstract class PreferenceGroup extends Preference implements GenericInfla
protected boolean isOnSameScreenAsChildren() { protected boolean isOnSameScreenAsChildren() {
return true; return true;
} }
@Override @Override
protected void onAttachedToActivity() { protected void onAttachedToActivity() {
super.onAttachedToActivity(); super.onAttachedToActivity();
@@ -283,17 +279,11 @@ public abstract class PreferenceGroup extends Preference implements GenericInfla
} }
@Override @Override
protected void onDetachedFromActivity() { protected void onPrepareForRemoval() {
super.onDetachedFromActivity(); super.onPrepareForRemoval();
// We won't be attached to the activity anymore // We won't be attached to the activity anymore
mAttachedToActivity = false; mAttachedToActivity = false;
// Dispatch to all contained preferences
final int preferenceCount = getPreferenceCount();
for (int i = 0; i < preferenceCount; i++) {
getPreference(i).onDetachedFromActivity();
}
} }
@Override @Override

View File

@@ -519,9 +519,6 @@ public class PreferenceManager {
*/ */
boolean setPreferences(PreferenceScreen preferenceScreen) { boolean setPreferences(PreferenceScreen preferenceScreen) {
if (preferenceScreen != mPreferenceScreen) { if (preferenceScreen != mPreferenceScreen) {
if (mPreferenceScreen != null) {
mPreferenceScreen.onDetachedFromActivity();
}
mPreferenceScreen = preferenceScreen; mPreferenceScreen = preferenceScreen;
return true; return true;
} }
@@ -830,11 +827,7 @@ public class PreferenceManager {
*/ */
void dispatchActivityDestroy() { void dispatchActivityDestroy() {
List<OnActivityDestroyListener> list = null; List<OnActivityDestroyListener> list = null;
if (mPreferenceScreen != null) {
mPreferenceScreen.onDetachedFromActivity();
mPreferenceScreen = null;
}
synchronized (this) { synchronized (this) {
if (mActivityDestroyListeners != null) { if (mActivityDestroyListeners != null) {
list = new ArrayList<OnActivityDestroyListener>(mActivityDestroyListeners); list = new ArrayList<OnActivityDestroyListener>(mActivityDestroyListeners);