some small style updates
This commit is contained in:
parent
b0b1becf88
commit
56a953b07c
|
@ -156,39 +156,35 @@ public class MyCanvas extends View {
|
||||||
void pathsChanged(int cnt);
|
void pathsChanged(int cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parcelable
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Parcelable onSaveInstanceState() {
|
public Parcelable onSaveInstanceState() {
|
||||||
Parcelable superState = super.onSaveInstanceState();
|
Parcelable superState = super.onSaveInstanceState();
|
||||||
SavedState ss = new SavedState(superState);
|
SavedState savedState = new SavedState(superState);
|
||||||
|
|
||||||
ss.mPaths = mPaths;
|
savedState.mPaths = mPaths;
|
||||||
return ss;
|
return savedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRestoreInstanceState(Parcelable state) {
|
public void onRestoreInstanceState(Parcelable state) {
|
||||||
if(!(state instanceof SavedState)) {
|
if (!(state instanceof SavedState)) {
|
||||||
super.onRestoreInstanceState(state);
|
super.onRestoreInstanceState(state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SavedState ss = (SavedState)state;
|
SavedState savedState = (SavedState) state;
|
||||||
super.onRestoreInstanceState(ss.getSuperState());
|
super.onRestoreInstanceState(savedState.getSuperState());
|
||||||
|
|
||||||
mPaths = ss.mPaths;
|
mPaths = savedState.mPaths;
|
||||||
pathsUpdated(); // This doesn't seem to be necessary
|
pathsUpdated(); // This doesn't seem to be necessary
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SavedState extends BaseSavedState {
|
static class SavedState extends BaseSavedState {
|
||||||
// Members
|
|
||||||
Map<MyPath, Integer> mPaths;
|
Map<MyPath, Integer> mPaths;
|
||||||
|
|
||||||
SavedState(Parcelable superState) {
|
SavedState(Parcelable superState) {
|
||||||
super(superState);
|
super(superState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
super.writeToParcel(out, flags);
|
super.writeToParcel(out, flags);
|
||||||
|
@ -199,12 +195,12 @@ public class MyCanvas extends View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load
|
|
||||||
public static final Parcelable.Creator<SavedState> CREATOR =
|
public static final Parcelable.Creator<SavedState> CREATOR =
|
||||||
new Parcelable.Creator<SavedState>() {
|
new Parcelable.Creator<SavedState>() {
|
||||||
public SavedState createFromParcel(Parcel in) {
|
public SavedState createFromParcel(Parcel in) {
|
||||||
return new SavedState(in);
|
return new SavedState(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SavedState[] newArray(int size) {
|
public SavedState[] newArray(int size) {
|
||||||
return new SavedState[size];
|
return new SavedState[size];
|
||||||
}
|
}
|
||||||
|
@ -214,7 +210,7 @@ public class MyCanvas extends View {
|
||||||
super(in);
|
super(in);
|
||||||
int size = in.readInt();
|
int size = in.readInt();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
MyPath key = (MyPath)in.readSerializable();
|
MyPath key = (MyPath) in.readSerializable();
|
||||||
int value = in.readInt();
|
int value = in.readInt();
|
||||||
mPaths.put(key, value);
|
mPaths.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue