Commit 247cfe16 authored by yangwu.jia's avatar yangwu.jia

解决页面切换 黑一下问题

parent 765e8977
package com.idlefish.flutterboost.containers; package com.idlefish.flutterboost.containers;
import android.content.Context; import android.content.Context;
import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
...@@ -43,7 +44,8 @@ public class FlutterSplashView extends FrameLayout { ...@@ -43,7 +44,8 @@ public class FlutterSplashView extends FrameLayout {
@Override @Override
public void onFlutterEngineAttachedToFlutterView(@NonNull FlutterEngine engine) { public void onFlutterEngineAttachedToFlutterView(@NonNull FlutterEngine engine) {
flutterView.removeFlutterEngineAttachmentListener(this); flutterView.removeFlutterEngineAttachmentListener(this);
displayFlutterViewWithSplash(flutterView, splashScreen); // displayFlutterViewWithSplash(flutterView, splashScreen);
// splashScreenTransitionNeededNow();
} }
@Override @Override
...@@ -131,25 +133,37 @@ public class FlutterSplashView extends FrameLayout { ...@@ -131,25 +133,37 @@ public class FlutterSplashView extends FrameLayout {
// Display the new splash screen, if needed. // Display the new splash screen, if needed.
if (splashScreen != null) { if (splashScreen != null) {
if (isSplashScreenNeededNow()) {
Log.v(TAG, "Showing splash screen UI.");
// This is the typical case. A FlutterEngine is attached to the FlutterView and we're
// waiting for the first frame to render. Show a splash UI until that happens.
splashScreenView = splashScreen.createSplashView(getContext(), splashScreenState); splashScreenView = splashScreen.createSplashView(getContext(), splashScreenState);
splashScreenView.setBackgroundColor(Color.WHITE);
addView(this.splashScreenView); addView(this.splashScreenView);
flutterView.addOnFirstFrameRenderedListener(onFirstFrameRenderedListener); flutterView.addOnFirstFrameRenderedListener(onFirstFrameRenderedListener);
} else if (isSplashScreenTransitionNeededNow()) {
Log.v(TAG, "Showing an immediate splash transition to Flutter due to previously interrupted transition.");
splashScreenView = splashScreen.createSplashView(getContext(), splashScreenState); // if (splashScreen != null) {
addView(splashScreenView); // if (this.isSplashScreenNeededNow()) {
transitionToFlutter(); // Log.v(TAG, "Showing splash screen UI.");
} else if (!flutterView.isAttachedToFlutterEngine()) { // this.splashScreenView = splashScreen.createSplashView(this.getContext(), this.splashScreenState);
Log.v(TAG, "FlutterView is not yet attached to a FlutterEngine. Showing nothing until a FlutterEngine is attached."); // this.addView(this.splashScreenView);
flutterView.addFlutterEngineAttachmentListener(flutterEngineAttachmentListener); // flutterView.addOnFirstFrameRenderedListener(this.onFirstFrameRenderedListener);
} // } else if (this.isSplashScreenTransitionNeededNow()) {
// Log.v(TAG, "Showing an immediate splash transition to Flutter due to previously interrupted transition.");
// this.splashScreenView = splashScreen.createSplashView(this.getContext(), this.splashScreenState);
// this.addView(this.splashScreenView);
// this.transitionToFlutter();
// } else if (!flutterView.isAttachedToFlutterEngine()) {
// Log.v(TAG, "FlutterView is not yet attached to a FlutterEngine. Showing nothing until a FlutterEngine is attached.");
// flutterView.addFlutterEngineAttachmentListener(this.flutterEngineAttachmentListener);
// }
// }
} }
} }
/** /**
* Returns true if current conditions require a splash UI to be displayed. * Returns true if current conditions require a splash UI to be displayed.
* <p> * <p>
......
...@@ -17,9 +17,8 @@ import android.os.Build; ...@@ -17,9 +17,8 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.view.View; import android.view.*;
import android.view.Window; import android.widget.*;
import android.view.WindowManager;
import com.idlefish.flutterboost.NewFlutterBoost; import com.idlefish.flutterboost.NewFlutterBoost;
import com.idlefish.flutterboost.Utils; import com.idlefish.flutterboost.Utils;
import io.flutter.Log; import io.flutter.Log;
...@@ -175,7 +174,7 @@ public class NewBoostFlutterActivity extends Activity ...@@ -175,7 +174,7 @@ public class NewBoostFlutterActivity extends Activity
public SplashScreen provideSplashScreen() { public SplashScreen provideSplashScreen() {
Drawable manifestSplashDrawable = getSplashScreenFromManifest(); Drawable manifestSplashDrawable = getSplashScreenFromManifest();
if (manifestSplashDrawable != null) { if (manifestSplashDrawable != null) {
return new DrawableSplashScreen(manifestSplashDrawable); return new DrawableSplashScreen(manifestSplashDrawable, ImageView.ScaleType.CENTER,500L);
} else { } else {
return null; return null;
} }
...@@ -469,8 +468,15 @@ public class NewBoostFlutterActivity extends Activity ...@@ -469,8 +468,15 @@ public class NewBoostFlutterActivity extends Activity
@Override @Override
public void onFirstFrameRendered() { public void onFirstFrameRendered() {
} }
@Override @Override
public void finishContainer(Map<String, Object> result) { public void finishContainer(Map<String, Object> result) {
Activity activity= this.getActivity(); Activity activity= this.getActivity();
......
...@@ -35,14 +35,13 @@ ...@@ -35,14 +35,13 @@
</activity> </activity>
<activity <activity
android:name="com.idlefish.flutterboost.containers.NewBoostFlutterActivity" android:name="com.idlefish.flutterboost.containers.NewBoostFlutterActivity"
android:theme="@style/Theme.AppCompat" android:theme="@style/Theme.AppCompat"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize" > android:windowSoftInputMode="adjustResize" >
<!--<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/page_loading"/>--> <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/page_loading"/>
</activity> </activity>
<activity <activity
......
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