* [android] Add try catch for FlatGUI
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/942d0320 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/942d0320 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/942d0320 Branch: refs/heads/0.16-dev Commit: 942d03202500019d665e29401eb91ba345e8e871 Parents: 94b4d41 Author: YorkShen <shenyua...@gmail.com> Authored: Fri Sep 8 11:43:41 2017 +0800 Committer: YorkShen <shenyua...@gmail.com> Committed: Wed Sep 13 16:55:22 2017 +0800 ---------------------------------------------------------------------- .../com/taobao/weex/ui/view/WXFrameLayout.java | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/942d0320/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java b/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java index 4156de8..28c7cef 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/view/WXFrameLayout.java @@ -29,6 +29,7 @@ import com.taobao.weex.ui.component.WXDiv; import com.taobao.weex.ui.flat.widget.Widget; import com.taobao.weex.ui.view.gesture.WXGesture; import com.taobao.weex.ui.view.gesture.WXGestureObservable; +import com.taobao.weex.utils.WXLogUtils; import com.taobao.weex.utils.WXViewUtils; import java.lang.ref.WeakReference; import java.util.List; @@ -95,16 +96,20 @@ public class WXFrameLayout extends FrameLayout implements WXGestureObservable,IR @Override protected void dispatchDraw(Canvas canvas) { - if (mWidgets != null) { - canvas.save(); - canvas.translate(getPaddingLeft(), getPaddingTop()); - for (Widget widget : mWidgets) { - widget.draw(canvas); + try { + if (mWidgets != null) { + canvas.save(); + canvas.translate(getPaddingLeft(), getPaddingTop()); + for (Widget widget : mWidgets) { + widget.draw(canvas); + } + canvas.restore(); + } else { + WXViewUtils.clipCanvasWithinBorderBox(this, canvas); + super.dispatchDraw(canvas); } - canvas.restore(); - } else { - WXViewUtils.clipCanvasWithinBorderBox(this, canvas); - super.dispatchDraw(canvas); + }catch (Throwable e){ + WXLogUtils.e("FlatGUI Crashed when dispatchDraw", WXLogUtils.getStackTrace(e)); } } }