From a49f83a61b8b6665730ee544b30b08f7dfcd4590 Mon Sep 17 00:00:00 2001 From: YorkShen Date: Tue, 20 Nov 2018 20:08:21 +0800 Subject: [PATCH] * [Android] Update 0 zero column report as column is not used when mLayoutType == TYPE_LINEAR_LAYOUT (#1785) --- .../taobao/weex/ui/component/list/WXListComponent.java | 8 ++++++-- .../component/list/template/WXRecyclerTemplateList.java | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXListComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXListComponent.java index a57557fc0d..96f3f14a25 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXListComponent.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXListComponent.java @@ -18,6 +18,8 @@ */ package com.taobao.weex.ui.component.list; +import static com.taobao.weex.ui.view.listview.WXRecyclerView.TYPE_LINEAR_LAYOUT; + import android.content.Context; import android.support.v4.util.ArrayMap; import android.support.v7.widget.PagerSnapHelper; @@ -171,13 +173,15 @@ public void run() { private void updateRecyclerAttr() { mColumnCount = WXUtils.parseInt(getAttrs().get(Constants.Name.COLUMN_COUNT)); - if (mColumnCount <= 0) { + if (mColumnCount <= 0 && mLayoutType != TYPE_LINEAR_LAYOUT) { + Map ext = new ArrayMap<>(); + ext.put("componentType", getComponentType()); WXExceptionUtils.commitCriticalExceptionRT(getInstanceId(), WXErrorCode.WX_RENDER_ERR_LIST_INVALID_COLUMN_COUNT, "columnCount", String.format(Locale.ENGLISH, "You are trying to set the list/recycler/vlist/waterfall's column to %d, which is illegal. The column count should be a positive integer", mColumnCount), - new ArrayMap()); + ext); mColumnCount = Constants.Value.COLUMN_COUNT_NORMAL; } mColumnGap = WXUtils.parseFloat(getAttrs().get(Constants.Name.COLUMN_GAP)); diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java index 8efcc2f512..93bdc2bf3e 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java @@ -19,6 +19,7 @@ package com.taobao.weex.ui.component.list.template; import static com.taobao.weex.common.Constants.Name.LOADMOREOFFSET; +import static com.taobao.weex.ui.view.listview.WXRecyclerView.TYPE_LINEAR_LAYOUT; import android.annotation.TargetApi; import android.content.Context; @@ -110,7 +111,7 @@ public class WXRecyclerTemplateList extends WXVContainer imp // TODO // private WXRecyclerDomObject mDomObject; - protected int mLayoutType = WXRecyclerView.TYPE_LINEAR_LAYOUT; + protected int mLayoutType = TYPE_LINEAR_LAYOUT; protected int mColumnCount = 1; protected float mColumnGap = 0; protected float mColumnWidth = 0; @@ -929,13 +930,15 @@ public void setOffsetAccuracy(int accuracy) { private void updateRecyclerAttr(){ mLayoutType = getAttrs().getLayoutType(); mColumnCount = getAttrs().getColumnCount(); - if (mColumnCount <= 0) { + if (mColumnCount <= 0 && mLayoutType != TYPE_LINEAR_LAYOUT) { + Map ext = new ArrayMap<>(); + ext.put("componentType", getComponentType()); WXExceptionUtils.commitCriticalExceptionRT(getInstanceId(), WXErrorCode.WX_RENDER_ERR_LIST_INVALID_COLUMN_COUNT, "columnCount", String.format(Locale.ENGLISH, "You are trying to set the list/recycler/vlist/waterfall's column to %d, which is illegal. The column count should be a positive integer", mColumnCount), - new ArrayMap()); + ext); mColumnCount = Constants.Value.COLUMN_COUNT_NORMAL; } mColumnGap = getAttrs().getColumnGap();