You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/03/06 02:54:27 UTC

[2/5] incubator-weex git commit: * [android] bugfix NPE

* [android] bugfix NPE


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/16633e3a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/16633e3a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/16633e3a

Branch: refs/heads/0.11-dev
Commit: 16633e3a05a37020ad2c9f2b80d2335591cf2c6e
Parents: 171f148
Author: zshshr <zh...@gmail.com>
Authored: Fri Mar 3 17:45:24 2017 +0800
Committer: zshshr <zh...@gmail.com>
Committed: Fri Mar 3 17:45:24 2017 +0800

----------------------------------------------------------------------
 .../ui/view/refresh/wrapper/BaseBounceView.java | 52 ++++++++++++--------
 1 file changed, 32 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/16633e3a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/wrapper/BaseBounceView.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/wrapper/BaseBounceView.java b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/wrapper/BaseBounceView.java
index e517ab1..c3f10ba 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/wrapper/BaseBounceView.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/wrapper/BaseBounceView.java
@@ -213,6 +213,7 @@ import android.view.View;
 import android.widget.FrameLayout;
 
 import com.taobao.weex.common.Constants;
+import com.taobao.weex.dom.ImmutableDomObject;
 import com.taobao.weex.ui.component.WXComponent;
 import com.taobao.weex.ui.view.WXLoadingLayout;
 import com.taobao.weex.ui.view.WXRefreshLayout;
@@ -303,21 +304,27 @@ public abstract class BaseBounceView<T extends View> extends FrameLayout {
     public void setHeaderView(WXComponent refresh) {
         setRefreshEnable(true);
         if (swipeLayout != null) {
-            if (swipeLayout.getHeaderView() != null) {
-                swipeLayout.setRefreshHeight((int) refresh.getDomObject().getLayoutHeight());
+            WXRefreshView refreshView = swipeLayout.getHeaderView();
+            if (refreshView != null) {
+                ImmutableDomObject immutableDomObject = refresh.getDomObject();
+                if (immutableDomObject == null) {
+                    int refreshHeight = (int) immutableDomObject.getLayoutHeight();
 
-                String colorStr = (String) refresh.getDomObject().getStyles().get(Constants.Name.BACKGROUND_COLOR);
-                String bgColor = WXUtils.getString(colorStr, null);
+                    swipeLayout.setRefreshHeight(refreshHeight);
 
-                if (bgColor != null) {
-                    if (!TextUtils.isEmpty(bgColor)) {
-                        int colorInt = WXResourceUtils.getColor(bgColor);
-                        if (!(colorInt == Color.TRANSPARENT)) {
-                            swipeLayout.setRefreshBgColor(colorInt);
+                    String colorStr = (String) immutableDomObject.getStyles().get(Constants.Name.BACKGROUND_COLOR);
+                    String bgColor = WXUtils.getString(colorStr, null);
+
+                    if (bgColor != null) {
+                        if (!TextUtils.isEmpty(bgColor)) {
+                            int colorInt = WXResourceUtils.getColor(bgColor);
+                            if (!(colorInt == Color.TRANSPARENT)) {
+                                swipeLayout.setRefreshBgColor(colorInt);
+                            }
                         }
                     }
+                    refreshView.setRefreshView(refresh.getHostView());
                 }
-                swipeLayout.getHeaderView().setRefreshView(refresh.getHostView());
             }
         }
     }
@@ -329,21 +336,26 @@ public abstract class BaseBounceView<T extends View> extends FrameLayout {
     public void setFooterView(WXComponent loading) {
         setLoadmoreEnable(true);
         if (swipeLayout != null) {
-            if (swipeLayout.getFooterView() != null) {
-                swipeLayout.setLoadingHeight((int) loading.getDomObject().getLayoutHeight());
+            WXRefreshView refreshView = swipeLayout.getFooterView();
+            if (refreshView != null) {
+                ImmutableDomObject object = loading.getDomObject();
+                if (object != null) {
+                    int loadingHeight = (int) loading.getDomObject().getLayoutHeight();
+                    swipeLayout.setLoadingHeight(loadingHeight);
 
-                String colorStr = (String) loading.getDomObject().getStyles().get(Constants.Name.BACKGROUND_COLOR);
-                String bgColor = WXUtils.getString(colorStr, null);
+                    String colorStr = (String) loading.getDomObject().getStyles().get(Constants.Name.BACKGROUND_COLOR);
+                    String bgColor = WXUtils.getString(colorStr, null);
 
-                if (bgColor != null) {
-                    if (!TextUtils.isEmpty(bgColor)) {
-                        int colorInt = WXResourceUtils.getColor(bgColor);
-                        if (!(colorInt == Color.TRANSPARENT)) {
-                            swipeLayout.setLoadingBgColor(colorInt);
+                    if (bgColor != null) {
+                        if (!TextUtils.isEmpty(bgColor)) {
+                            int colorInt = WXResourceUtils.getColor(bgColor);
+                            if (!(colorInt == Color.TRANSPARENT)) {
+                                swipeLayout.setLoadingBgColor(colorInt);
+                            }
                         }
                     }
+                    refreshView.setRefreshView(loading.getHostView());
                 }
-                swipeLayout.getFooterView().setRefreshView(loading.getHostView());
             }
         }
     }