| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view; |
| 18 |
|
| 19 |
import android.os.Parcel; |
| 20 |
import android.os.Parcelable; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public abstract class AbsSavedState implements Parcelable { |
| 27 |
public static final AbsSavedState EMPTY_STATE = new AbsSavedState() {}; |
| 28 |
|
| 29 |
private final Parcelable mSuperState; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
private AbsSavedState() { |
| 35 |
mSuperState = null; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
protected AbsSavedState(Parcelable superState) { |
| 44 |
if (superState == null) { |
| 45 |
throw new IllegalArgumentException("superState must not be null"); |
| 46 |
} |
| 47 |
mSuperState = superState != EMPTY_STATE ? superState : null; |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
protected AbsSavedState(Parcel source) { |
| 56 |
this(source, null); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
protected AbsSavedState(Parcel source, ClassLoader loader) { |
| 67 |
Parcelable superState = source.readParcelable(loader); |
| 68 |
mSuperState = superState != null ? superState : EMPTY_STATE; |
| 69 |
} |
| 70 |
|
| 71 |
final public Parcelable getSuperState() { |
| 72 |
return mSuperState; |
| 73 |
} |
| 74 |
|
| 75 |
public int describeContents() { |
| 76 |
return 0; |
| 77 |
} |
| 78 |
|
| 79 |
public void writeToParcel(Parcel dest, int flags) { |
| 80 |
dest.writeParcelable(mSuperState, flags); |
| 81 |
} |
| 82 |
|
| 83 |
public static final @android.annotation.NonNull Parcelable.Creator<AbsSavedState> CREATOR |
| 84 |
= new Parcelable.ClassLoaderCreator<AbsSavedState>() { |
| 85 |
|
| 86 |
@Override |
| 87 |
public AbsSavedState createFromParcel(Parcel in) { |
| 88 |
return createFromParcel(in, null); |
| 89 |
} |
| 90 |
|
| 91 |
@Override |
| 92 |
public AbsSavedState createFromParcel(Parcel in, ClassLoader loader) { |
| 93 |
Parcelable superState = in.readParcelable(loader); |
| 94 |
if (superState != null) { |
| 95 |
throw new IllegalStateException("superState must be null"); |
| 96 |
} |
| 97 |
return EMPTY_STATE; |
| 98 |
} |
| 99 |
|
| 100 |
@Override |
| 101 |
public AbsSavedState[] newArray(int size) { |
| 102 |
return new AbsSavedState[size]; |
| 103 |
} |
| 104 |
}; |
| 105 |
} |