Commit 925e30e8 authored by yangwu.jia's avatar yangwu.jia

onRestoreInstanceState 问题修复

parent 978ca55c
...@@ -92,23 +92,22 @@ public class FlutterSplashView extends FrameLayout { ...@@ -92,23 +92,22 @@ public class FlutterSplashView extends FrameLayout {
} }
@Nullable @Nullable
@Override
protected Parcelable onSaveInstanceState() { protected Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState(); Parcelable superState = super.onSaveInstanceState();
SavedState savedState = new SavedState(superState); FlutterSplashView.SavedState savedState = new FlutterSplashView.SavedState(superState);
savedState.previousCompletedSplashIsolate = previousCompletedSplashIsolate; savedState.previousCompletedSplashIsolate = this.previousCompletedSplashIsolate;
savedState.splashScreenState = splashScreen != null ? splashScreen.saveSplashScreenState() : null; savedState.splashScreenState = this.splashScreen != null ? this.splashScreen.saveSplashScreenState() : null;
return savedState; return savedState;
} }
@Override
protected void onRestoreInstanceState(Parcelable state) { protected void onRestoreInstanceState(Parcelable state) {
SavedState savedState = (SavedState) state; FlutterSplashView.SavedState savedState = (FlutterSplashView.SavedState)state;
super.onRestoreInstanceState(savedState.getSuperState()); super.onRestoreInstanceState(savedState.getSuperState());
previousCompletedSplashIsolate = savedState.previousCompletedSplashIsolate; this.previousCompletedSplashIsolate = savedState.previousCompletedSplashIsolate;
splashScreenState = savedState.splashScreenState; this.splashScreenState = savedState.splashScreenState;
} }
/** /**
* Displays the given {@code splashScreen} on top of the given {@code flutterView} until * Displays the given {@code splashScreen} on top of the given {@code flutterView} until
* Flutter has rendered its first frame, then the {@code splashScreen} is transitioned away. * Flutter has rendered its first frame, then the {@code splashScreen} is transitioned away.
...@@ -259,17 +258,14 @@ public class FlutterSplashView extends FrameLayout { ...@@ -259,17 +258,14 @@ public class FlutterSplashView extends FrameLayout {
public static class SavedState extends BaseSavedState { public static class SavedState extends BaseSavedState {
public static Creator CREATOR = new Creator() { public static Creator CREATOR = new Creator() {
@Override public FlutterSplashView.SavedState createFromParcel(Parcel source) {
public SavedState createFromParcel(Parcel source) { return new FlutterSplashView.SavedState(source);
return new SavedState(source);
} }
@Override public FlutterSplashView.SavedState[] newArray(int size) {
public SavedState[] newArray(int size) { return new FlutterSplashView.SavedState[size];
return new SavedState[size];
} }
}; };
private String previousCompletedSplashIsolate; private String previousCompletedSplashIsolate;
private Bundle splashScreenState; private Bundle splashScreenState;
...@@ -279,15 +275,14 @@ public class FlutterSplashView extends FrameLayout { ...@@ -279,15 +275,14 @@ public class FlutterSplashView extends FrameLayout {
SavedState(Parcel source) { SavedState(Parcel source) {
super(source); super(source);
previousCompletedSplashIsolate = source.readString(); this.previousCompletedSplashIsolate = source.readString();
splashScreenState = source.readBundle(getClass().getClassLoader()); this.splashScreenState = source.readBundle(this.getClass().getClassLoader());
} }
@Override
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags); super.writeToParcel(out, flags);
out.writeString(previousCompletedSplashIsolate); out.writeString(this.previousCompletedSplashIsolate);
out.writeBundle(splashScreenState); out.writeBundle(this.splashScreenState);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment