Merge "Fixed calls to update() when configuration changed." into nyc-dev
am: f4f2211b13
* commit 'f4f2211b1364422abec41e056af77c03247c3f4e':
Fixed calls to update() when configuration changed.
Change-Id: Ia35d89560fe2dd51d1c0dc8da3d1209c2cb03622
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index c81ec53..442c8e3 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -118,7 +118,7 @@
private Preference mExplore;
- private boolean mDetached;
+ private boolean mNeedsUpdate;
private boolean isVolumeValid() {
return (mVolume != null) && (mVolume.getType() == VolumeInfo.TYPE_PRIVATE)
@@ -165,18 +165,22 @@
mExplore = buildAction(R.string.storage_menu_explore);
- mDetached = false;
+ mNeedsUpdate = true;
setHasOptionsMenu(true);
}
+ private void setTitle() {
+ getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
+ }
+
private void update() {
if (!isVolumeValid()) {
getActivity().finish();
return;
}
- getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
+ setTitle();
// Valid options may have changed
getFragmentManager().invalidateOptionsMenu();
@@ -239,6 +243,7 @@
mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
mMeasure.forceMeasure();
+ mNeedsUpdate = false;
}
private void addPreference(PreferenceGroup group, Preference pref) {
@@ -315,8 +320,10 @@
mStorageManager.registerListener(mStorageListener);
- if (!mDetached) {
+ if (mNeedsUpdate) {
update();
+ } else {
+ setTitle();
}
}
@@ -327,24 +334,11 @@
}
@Override
- public void onAttach(Context context) {
- super.onAttach(context);
- mDetached = false;
- }
-
- @Override
- public void onDetach() {
- super.onDetach();
- mDetached = true;
- }
-
- @Override
public void onDestroy() {
super.onDestroy();
if (mMeasure != null) {
mMeasure.onDestroy();
}
- mDetached = false;
}
@Override