You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/11/26 09:24:22 UTC

[GitHub] YorkShen closed pull request #1816: [WEEX-669][android] fix slider crash when adapter is null

YorkShen closed pull request #1816: [WEEX-669][android] fix slider crash when adapter is null
URL: https://github.com/apache/incubator-weex/pull/1816
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionLayout.java b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionLayout.java
index 45846cf988..24946fea87 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionLayout.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionLayout.java
@@ -41,7 +41,7 @@ public void executeAction() {
     }
 
     component.setDemission(mLayoutSize, mLayoutPosition);
-    component.setLayout(component);
+    component.setSafeLayout(component);
     component.setPadding(component.getPadding(), component.getBorder());
   }
 }
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
index fbf8bc3279..4d9447168d 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
@@ -682,7 +682,7 @@ public void applyLayoutAndEvent(WXComponent component) {
         component = this;
       }
       bindComponent(component);
-      setLayout(component);
+      setSafeLayout(component);
       setPadding(component.getPadding(), component.getBorder());
       applyEvents();
     }
@@ -701,7 +701,7 @@ public void updateDemission(float top, float bottom, float left, float right, fl
 
   public void applyLayoutOnly(){
     if(!isLazy()) {
-      setLayout(this);
+      setSafeLayout(this);
       setPadding(this.getPadding(), this.getBorder());
     }
   }
@@ -922,13 +922,19 @@ protected BorderDrawable getOrCreateBorder() {
   /**
    * layout view
    */
-  public void setLayout(WXComponent component) {
+  public void setSafeLayout(WXComponent component) {
     if (TextUtils.isEmpty(component.getComponentType())
             || TextUtils.isEmpty(component.getRef()) || component.getLayoutPosition() == null
             || component.getLayoutSize() == null) {
       return;
     }
+    setLayout(component);
+  }
 
+  /**
+   * layout view
+   */
+  public void setLayout(WXComponent component) {
     setLayoutSize(component.getLayoutSize());
     setLayoutPosition(component.getLayoutPosition());
     setPaddings(component.getPadding());
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSlider.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSlider.java
index 8e9474069f..d0033185b3 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSlider.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSlider.java
@@ -214,7 +214,9 @@ public void run() {
 
   @Override
   public void setLayout(WXComponent component) {
-    mAdapter.setLayoutDirectionRTL(this.isNativeLayoutRTL());
+    if (mAdapter != null) {
+      mAdapter.setLayoutDirectionRTL(this.isNativeLayoutRTL());
+    }
     super.setLayout(component);
   }
 
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
index a9a2c67910..c994707cfe 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
@@ -198,11 +198,6 @@ public void setMarginsSupportRTL(ViewGroup.MarginLayoutParams lp, int left, int
 
   @Override
   public void setLayout(WXComponent component) {
-    if (TextUtils.isEmpty(component.getComponentType())
-            || TextUtils.isEmpty(component.getRef()) || component.getLayoutPosition() == null
-            || component.getLayoutSize() == null) {
-      return;
-    }
     if (component.getHostView() != null) {
       int layoutDirection = component.isNativeLayoutRTL() ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR;
       ViewCompat.setLayoutDirection(component.getHostView(), layoutDirection);
diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/ComponentTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/ComponentTest.java
index 1e74e7a5ee..bcafc2a19f 100644
--- a/android/sdk/src/test/java/com/taobao/weex/ui/component/ComponentTest.java
+++ b/android/sdk/src/test/java/com/taobao/weex/ui/component/ComponentTest.java
@@ -49,7 +49,7 @@ public static void create(WXComponent comp,View view){
       parent.createChildViewAt(-1);
     }
 
-    comp.setLayout(comp);
+    comp.setSafeLayout(comp);
 
 //    domObject = new TestDomObject();
 //    comp.updateDom(domObject);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services