|
@@ -6,6 +6,8 @@ import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
import android.os.Build;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
+import android.os.Parcel;
|
|
|
|
+import android.os.Parcelable;
|
|
import android.preference.MultiSelectListPreference;
|
|
import android.preference.MultiSelectListPreference;
|
|
import android.preference.PreferenceManager;
|
|
import android.preference.PreferenceManager;
|
|
import android.util.AttributeSet;
|
|
import android.util.AttributeSet;
|
|
@@ -119,4 +121,67 @@ public class MaterialMultiSelectListPreference extends MultiSelectListPreference
|
|
if (mDialog != null && mDialog.isShowing())
|
|
if (mDialog != null && mDialog.isShowing())
|
|
mDialog.dismiss();
|
|
mDialog.dismiss();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected Parcelable onSaveInstanceState() {
|
|
|
|
+ final Parcelable superState = super.onSaveInstanceState();
|
|
|
|
+ Dialog dialog = getDialog();
|
|
|
|
+ if (dialog == null || !dialog.isShowing()) {
|
|
|
|
+ return superState;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ final SavedState myState = new SavedState(superState);
|
|
|
|
+ myState.isDialogShowing = true;
|
|
|
|
+ myState.dialogBundle = dialog.onSaveInstanceState();
|
|
|
|
+ return myState;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void onRestoreInstanceState(Parcelable state) {
|
|
|
|
+ if (state == null || !state.getClass().equals(SavedState.class)) {
|
|
|
|
+ // Didn't save state for us in onSaveInstanceState
|
|
|
|
+ super.onRestoreInstanceState(state);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SavedState myState = (SavedState) state;
|
|
|
|
+ super.onRestoreInstanceState(myState.getSuperState());
|
|
|
|
+ if (myState.isDialogShowing) {
|
|
|
|
+ showDialog(myState.dialogBundle);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // From DialogPreference
|
|
|
|
+ private static class SavedState extends BaseSavedState {
|
|
|
|
+ boolean isDialogShowing;
|
|
|
|
+ Bundle dialogBundle;
|
|
|
|
+
|
|
|
|
+ public SavedState(Parcel source) {
|
|
|
|
+ super(source);
|
|
|
|
+ isDialogShowing = source.readInt() == 1;
|
|
|
|
+ dialogBundle = source.readBundle();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void writeToParcel(Parcel dest, int flags) {
|
|
|
|
+ super.writeToParcel(dest, flags);
|
|
|
|
+ dest.writeInt(isDialogShowing ? 1 : 0);
|
|
|
|
+ dest.writeBundle(dialogBundle);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public SavedState(Parcelable superState) {
|
|
|
|
+ super(superState);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static final Parcelable.Creator<SavedState> CREATOR =
|
|
|
|
+ new Parcelable.Creator<SavedState>() {
|
|
|
|
+ public SavedState createFromParcel(Parcel in) {
|
|
|
|
+ return new SavedState(in);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public SavedState[] newArray(int size) {
|
|
|
|
+ return new SavedState[size];
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
}
|
|
}
|