Commit 2c898736 authored by Yacumima's avatar Yacumima

页面切换闪烁优化

parent 3c4a70e6
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
*/ */
package com.taobao.idlefish.flutterboost; package com.taobao.idlefish.flutterboost;
import android.os.Handler;
import com.taobao.idlefish.flutterboost.NavigationService.NavigationService; import com.taobao.idlefish.flutterboost.NavigationService.NavigationService;
import com.taobao.idlefish.flutterboost.interfaces.IContainerManager; import com.taobao.idlefish.flutterboost.interfaces.IContainerManager;
import com.taobao.idlefish.flutterboost.interfaces.IContainerRecord; import com.taobao.idlefish.flutterboost.interfaces.IContainerRecord;
...@@ -36,6 +38,7 @@ public class ContainerRecord implements IContainerRecord { ...@@ -36,6 +38,7 @@ public class ContainerRecord implements IContainerRecord {
private final IContainerManager mManager; private final IContainerManager mManager;
private final IFlutterViewContainer mContainer; private final IFlutterViewContainer mContainer;
private final String mUniqueId; private final String mUniqueId;
private final Handler mHandler = new Handler();
private int mState = STATE_UNKNOW; private int mState = STATE_UNKNOW;
private MethodChannelProxy mProxy = new MethodChannelProxy(); private MethodChannelProxy mProxy = new MethodChannelProxy();
...@@ -85,8 +88,13 @@ public class ContainerRecord implements IContainerRecord { ...@@ -85,8 +88,13 @@ public class ContainerRecord implements IContainerRecord {
* If current container is finishing, we should call destroy flutter page early. * If current container is finishing, we should call destroy flutter page early.
*/ */
if(mContainer.isFinishing()) { if(mContainer.isFinishing()) {
mHandler.post(new Runnable() {
@Override
public void run() {
mProxy.destroy(); mProxy.destroy();
} }
});
}
} }
@Override @Override
......
...@@ -144,12 +144,11 @@ abstract public class FlutterViewStub extends FrameLayout { ...@@ -144,12 +144,11 @@ abstract public class FlutterViewStub extends FrameLayout {
if (flutterView == null) return; if (flutterView == null) return;
Debuger.log("detachFlutterView");
if (mSnapshot.getParent() == null) { if (mSnapshot.getParent() == null) {
mBitmap = flutterView.getBitmap(); mBitmap = flutterView.getBitmap();
if (mBitmap != null && !mBitmap.isRecycled()) { if (mBitmap != null && !mBitmap.isRecycled()) {
mSnapshot.setImageBitmap(mBitmap); mSnapshot.setImageBitmap(mBitmap);
Debuger.log("snapshot view");
addView(mSnapshot); addView(mSnapshot);
} }
} }
...@@ -160,11 +159,12 @@ abstract public class FlutterViewStub extends FrameLayout { ...@@ -160,11 +159,12 @@ abstract public class FlutterViewStub extends FrameLayout {
@Override @Override
public void run() { public void run() {
if (flutterView.getParent() != null && flutterView.getParent() == mStub) { if (flutterView.getParent() != null && flutterView.getParent() == mStub) {
Debuger.log("detachFlutterView");
mStub.removeView(flutterView); mStub.removeView(flutterView);
} }
} }
}; };
sHandler.sendMessage(msg); sHandler.sendMessageDelayed(msg,18);
} }
public void destroy() { public void destroy() {
......
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