You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@weex.apache.org by GitBox <gi...@apache.org> on 2018/09/25 06:37:09 UTC

[GitHub] YorkShen closed pull request #1571: [WEEX-631][Android] fix ListComponent column gap problem

YorkShen closed pull request #1571: [WEEX-631][Android] fix ListComponent column gap problem
URL: https://github.com/apache/incubator-weex/pull/1571
 
 
   

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/component/list/BasicListComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
index 537f22872c..e025c3b850 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
@@ -215,7 +215,7 @@ protected MeasureOutput measure(int width, int height) {
     int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication);
     int weexH = WXViewUtils.getWeexHeight(getInstanceId());
     int outHeight = height > (weexH >= screenH ? screenH : weexH) ? weexH - getAbsoluteY() : height;
-    return super.measure((int)(width+mColumnGap), outHeight);
+    return super.measure(width, outHeight);
   }
 
   public int getOrientation() {
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 c6583d0389..916d895367 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
@@ -399,7 +399,7 @@ protected MeasureOutput measure(int width, int height) {
         int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication);
         int weexH = WXViewUtils.getWeexHeight(getInstanceId());
         int outHeight = height > (weexH >= screenH ? screenH : weexH) ? weexH - getAbsoluteY() : height;
-        return super.measure((int)(width+mColumnGap), outHeight);
+        return super.measure(width, outHeight);
     }
 
 
diff --git a/weex_core/Source/core/render/node/render_list.cpp b/weex_core/Source/core/render/node/render_list.cpp
index 85df905ce1..c58d138c2f 100644
--- a/weex_core/Source/core/render/node/render_list.cpp
+++ b/weex_core/Source/core/render/node/render_list.cpp
@@ -198,13 +198,17 @@ void RenderList::PreCalculateCellWidth() {
 
 std::string RenderList::CalculateSpanOffset() {
   std::string span_offsets;
-  if (this->left_gap_ > 0 || this->right_gap_ > 0) {
+  float divide = available_width_ / column_count_;
+  float item_start_pos = 0;
+  if (this->left_gap_ > 0 || this->right_gap_ > 0 || column_gap_ > 0) {
     span_offsets.append("[");
     for (int i = 0; i < this->column_count_; i++) {
-      float span_offset =
-          this->left_gap_ + i * ((this->column_width_ + this->column_gap_) -
-                                 (this->available_width_ + this->column_gap_) /
-                                     this->column_count_);
+      if (i == 0) {
+        item_start_pos += left_gap_;
+      } else {
+        item_start_pos += column_gap_ + column_width_;
+      }
+      float span_offset = item_start_pos - i * divide;
       span_offsets.append(to_string(span_offset));
       if (i != this->column_count_ - 1) {
         span_offsets.append(",");


 

----------------------------------------------------------------
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