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

修复闪一下问题

parent f7287a70
......@@ -686,7 +686,7 @@ public class XFlutterView extends FrameLayout {
resolveMemoryLeaks();
// Instruct our FlutterRenderer that we are no longer interested in being its RenderSurface.
FlutterRenderer flutterRenderer = flutterEngine.getRenderer();
didRenderFirstFrame = false;
// didRenderFirstFrame = false;
flutterRenderer.removeOnFirstFrameRenderedListener(onFirstFrameRenderedListener);
flutterRenderer.detachFromRenderSurface();
flutterEngine = null;
......
......@@ -28,7 +28,6 @@ import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.*;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.embedding.engine.renderer.OnFirstFrameRenderedListener;
import io.flutter.plugin.platform.PlatformPlugin;
import io.flutter.view.FlutterMain;
......@@ -56,15 +55,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
protected IOperateSyncer mSyncer;
@NonNull
private final OnFirstFrameRenderedListener onFirstFrameRenderedListener = new OnFirstFrameRenderedListener() {
@Override
public void onFirstFrameRendered() {
if(host!=null){
host.onFirstFrameRendered();
}
}
};
FlutterActivityAndFragmentDelegate(@NonNull Host host) {
this.host = host;
......@@ -171,7 +162,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
ensureAlive();
flutterView = new XFlutterView(host.getActivity(), NewFlutterBoost.instance().platform().renderMode(), host.getTransparencyMode());
flutterView.addOnFirstFrameRenderedListener(onFirstFrameRenderedListener);
flutterSplashView = new FlutterSplashView(host.getContext());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
......@@ -247,7 +237,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
mSyncer.onDestroy();
ensureAlive();
flutterView.removeOnFirstFrameRenderedListener(onFirstFrameRenderedListener);
}
......@@ -512,11 +501,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
*/
boolean shouldAttachEngineToActivity();
/**
* Invoked by this delegate when its {@link FlutterView} has rendered its first Flutter
* frame.
*/
void onFirstFrameRendered();
void finishContainer(Map<String, Object> result) ;
......
......@@ -39,6 +39,8 @@ public class FlutterSplashView extends FrameLayout {
@Nullable
private String previousCompletedSplashIsolate;
private boolean hasRendered=false;
@NonNull
private final FlutterView.FlutterEngineAttachmentListener flutterEngineAttachmentListener = new FlutterView.FlutterEngineAttachmentListener() {
@Override
......@@ -57,8 +59,11 @@ public class FlutterSplashView extends FrameLayout {
private final OnFirstFrameRenderedListener onFirstFrameRenderedListener = new OnFirstFrameRenderedListener() {
@Override
public void onFirstFrameRendered() {
if (splashScreen != null) {
if (splashScreen != null&&!hasRendered) {
transitionToFlutter();
hasRendered=true;
Log.i("xxxxxx22222",this.hashCode()+"");
}
}
};
......
......@@ -466,14 +466,6 @@ public class NewBoostFlutterActivity extends Activity
return true;
}
@Override
public void onFirstFrameRendered() {
}
......
......@@ -232,20 +232,6 @@ public class NewFlutterFragment extends Fragment implements FlutterActivityAndFr
// implementation for details about why it exists.
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() {
// 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
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
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