Commit 652c012f authored by yangwu.jia's avatar yangwu.jia

修复闪一下问题

parent f7287a70
...@@ -686,7 +686,7 @@ public class XFlutterView extends FrameLayout { ...@@ -686,7 +686,7 @@ public class XFlutterView extends FrameLayout {
resolveMemoryLeaks(); resolveMemoryLeaks();
// Instruct our FlutterRenderer that we are no longer interested in being its RenderSurface. // Instruct our FlutterRenderer that we are no longer interested in being its RenderSurface.
FlutterRenderer flutterRenderer = flutterEngine.getRenderer(); FlutterRenderer flutterRenderer = flutterEngine.getRenderer();
didRenderFirstFrame = false; // didRenderFirstFrame = false;
flutterRenderer.removeOnFirstFrameRenderedListener(onFirstFrameRenderedListener); flutterRenderer.removeOnFirstFrameRenderedListener(onFirstFrameRenderedListener);
flutterRenderer.detachFromRenderSurface(); flutterRenderer.detachFromRenderSurface();
flutterEngine = null; flutterEngine = null;
......
...@@ -28,7 +28,6 @@ import io.flutter.app.FlutterActivity; ...@@ -28,7 +28,6 @@ import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.*; import io.flutter.embedding.android.*;
import io.flutter.embedding.engine.FlutterEngine; import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterShellArgs; import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.embedding.engine.renderer.OnFirstFrameRenderedListener;
import io.flutter.plugin.platform.PlatformPlugin; import io.flutter.plugin.platform.PlatformPlugin;
import io.flutter.view.FlutterMain; import io.flutter.view.FlutterMain;
...@@ -56,15 +55,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine ...@@ -56,15 +55,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
protected IOperateSyncer mSyncer; protected IOperateSyncer mSyncer;
@NonNull
private final OnFirstFrameRenderedListener onFirstFrameRenderedListener = new OnFirstFrameRenderedListener() {
@Override
public void onFirstFrameRendered() {
if(host!=null){
host.onFirstFrameRendered();
}
}
};
FlutterActivityAndFragmentDelegate(@NonNull Host host) { FlutterActivityAndFragmentDelegate(@NonNull Host host) {
this.host = host; this.host = host;
...@@ -171,7 +162,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine ...@@ -171,7 +162,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
ensureAlive(); ensureAlive();
flutterView = new XFlutterView(host.getActivity(), NewFlutterBoost.instance().platform().renderMode(), host.getTransparencyMode()); flutterView = new XFlutterView(host.getActivity(), NewFlutterBoost.instance().platform().renderMode(), host.getTransparencyMode());
flutterView.addOnFirstFrameRenderedListener(onFirstFrameRenderedListener);
flutterSplashView = new FlutterSplashView(host.getContext()); flutterSplashView = new FlutterSplashView(host.getContext());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
...@@ -247,7 +237,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine ...@@ -247,7 +237,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
mSyncer.onDestroy(); mSyncer.onDestroy();
ensureAlive(); ensureAlive();
flutterView.removeOnFirstFrameRenderedListener(onFirstFrameRenderedListener);
} }
...@@ -512,11 +501,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine ...@@ -512,11 +501,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
*/ */
boolean shouldAttachEngineToActivity(); boolean shouldAttachEngineToActivity();
/**
* Invoked by this delegate when its {@link FlutterView} has rendered its first Flutter
* frame.
*/
void onFirstFrameRendered();
void finishContainer(Map<String, Object> result) ; void finishContainer(Map<String, Object> result) ;
......
...@@ -39,6 +39,8 @@ public class FlutterSplashView extends FrameLayout { ...@@ -39,6 +39,8 @@ public class FlutterSplashView extends FrameLayout {
@Nullable @Nullable
private String previousCompletedSplashIsolate; private String previousCompletedSplashIsolate;
private boolean hasRendered=false;
@NonNull @NonNull
private final FlutterView.FlutterEngineAttachmentListener flutterEngineAttachmentListener = new FlutterView.FlutterEngineAttachmentListener() { private final FlutterView.FlutterEngineAttachmentListener flutterEngineAttachmentListener = new FlutterView.FlutterEngineAttachmentListener() {
@Override @Override
...@@ -57,8 +59,11 @@ public class FlutterSplashView extends FrameLayout { ...@@ -57,8 +59,11 @@ public class FlutterSplashView extends FrameLayout {
private final OnFirstFrameRenderedListener onFirstFrameRenderedListener = new OnFirstFrameRenderedListener() { private final OnFirstFrameRenderedListener onFirstFrameRenderedListener = new OnFirstFrameRenderedListener() {
@Override @Override
public void onFirstFrameRendered() { public void onFirstFrameRendered() {
if (splashScreen != null) { if (splashScreen != null&&!hasRendered) {
transitionToFlutter(); transitionToFlutter();
hasRendered=true;
Log.i("xxxxxx22222",this.hashCode()+"");
} }
} }
}; };
......
...@@ -466,14 +466,6 @@ public class NewBoostFlutterActivity extends Activity ...@@ -466,14 +466,6 @@ public class NewBoostFlutterActivity extends Activity
return true; return true;
} }
@Override
public void onFirstFrameRendered() {
}
......
...@@ -232,20 +232,6 @@ public class NewFlutterFragment extends Fragment implements FlutterActivityAndFr ...@@ -232,20 +232,6 @@ public class NewFlutterFragment extends Fragment implements FlutterActivityAndFr
// implementation for details about why it exists. // implementation for details about why it exists.
private FlutterActivityAndFragmentDelegate delegate; private FlutterActivityAndFragmentDelegate delegate;
private final OnFirstFrameRenderedListener onFirstFrameRenderedListener = new OnFirstFrameRenderedListener() {
@Override
public void onFirstFrameRendered() {
// Notify our subclasses that the first frame has been rendered.
NewFlutterFragment.this.onFirstFrameRendered();
// Notify our owning Activity that the first frame has been rendered.
FragmentActivity fragmentActivity = getActivity();
if (fragmentActivity instanceof OnFirstFrameRenderedListener) {
OnFirstFrameRenderedListener activityAsListener = (OnFirstFrameRenderedListener) fragmentActivity;
activityAsListener.onFirstFrameRendered();
}
}
};
public NewFlutterFragment() { public NewFlutterFragment() {
// Ensure that we at least have an empty Bundle of arguments so that we don't // Ensure that we at least have an empty Bundle of arguments so that we don't
...@@ -502,24 +488,6 @@ public class NewFlutterFragment extends Fragment implements FlutterActivityAndFr ...@@ -502,24 +488,6 @@ public class NewFlutterFragment extends Fragment implements FlutterActivityAndFr
return getArguments().getBoolean(ARG_SHOULD_ATTACH_ENGINE_TO_ACTIVITY); return getArguments().getBoolean(ARG_SHOULD_ATTACH_ENGINE_TO_ACTIVITY);
} }
/**
* Invoked after the {@link FlutterView} within this {@code NewFlutterFragment} renders its first
* frame.
* <p>
* This method forwards {@code onFirstFrameRendered()} to its attached {@code Activity}, if
* the attached {@code Activity} implements {@link OnFirstFrameRenderedListener}.
* <p>
* Subclasses that override this method must call through to the {@code super} method.
* <p>
* Used by this {@code NewFlutterFragment}'s {@link FlutterActivityAndFragmentDelegate.Host}
*/
@Override
public void onFirstFrameRendered() {
FragmentActivity attachedActivity = getActivity();
if (attachedActivity instanceof OnFirstFrameRenderedListener) {
((OnFirstFrameRenderedListener) attachedActivity).onFirstFrameRendered();
}
}
@Override @Override
public void finishContainer(Map<String, Object> result) { public void finishContainer(Map<String, Object> result) {
......
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