提交 e28c06a5 编写于 作者: T Takeshi Hagikura 提交者: GitHub

Fix the issue that dividers become invisible when there is a gone view in the middle (#361)

上级 3fd14340
...@@ -927,21 +927,21 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer { ...@@ -927,21 +927,21 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer {
* {@code false} otherwise * {@code false} otherwise
*/ */
private void drawDividersHorizontal(Canvas canvas, boolean isRtl, boolean fromBottomToTop) { private void drawDividersHorizontal(Canvas canvas, boolean isRtl, boolean fromBottomToTop) {
int currentViewIndex = 0;
int paddingLeft = getPaddingLeft(); int paddingLeft = getPaddingLeft();
int paddingRight = getPaddingRight(); int paddingRight = getPaddingRight();
int horizontalDividerLength = Math.max(0, getWidth() - paddingRight - paddingLeft); int horizontalDividerLength = Math.max(0, getWidth() - paddingRight - paddingLeft);
for (int i = 0, size = mFlexLines.size(); i < size; i++) { for (int i = 0, size = mFlexLines.size(); i < size; i++) {
FlexLine flexLine = mFlexLines.get(i); FlexLine flexLine = mFlexLines.get(i);
for (int j = 0; j < flexLine.mItemCount; j++) { for (int j = 0; j < flexLine.mItemCount; j++) {
View view = getReorderedChildAt(currentViewIndex); int viewIndex = flexLine.mFirstIndex + j;
View view = getReorderedChildAt(viewIndex);
if (view == null || view.getVisibility() == View.GONE) { if (view == null || view.getVisibility() == View.GONE) {
continue; continue;
} }
LayoutParams lp = (LayoutParams) view.getLayoutParams(); LayoutParams lp = (LayoutParams) view.getLayoutParams();
// Judge if the beginning or middle divider is needed // Judge if the beginning or middle divider is needed
if (hasDividerBeforeChildAtAlongMainAxis(currentViewIndex, j)) { if (hasDividerBeforeChildAtAlongMainAxis(viewIndex, j)) {
int dividerLeft; int dividerLeft;
if (isRtl) { if (isRtl) {
dividerLeft = view.getRight() + lp.rightMargin; dividerLeft = view.getRight() + lp.rightMargin;
...@@ -966,7 +966,6 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer { ...@@ -966,7 +966,6 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer {
flexLine.mCrossSize); flexLine.mCrossSize);
} }
} }
currentViewIndex++;
} }
// Judge if the beginning or middle dividers are needed before the flex line // Judge if the beginning or middle dividers are needed before the flex line
...@@ -1008,7 +1007,6 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer { ...@@ -1008,7 +1007,6 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer {
* {@code false} otherwise * {@code false} otherwise
*/ */
private void drawDividersVertical(Canvas canvas, boolean isRtl, boolean fromBottomToTop) { private void drawDividersVertical(Canvas canvas, boolean isRtl, boolean fromBottomToTop) {
int currentViewIndex = 0;
int paddingTop = getPaddingTop(); int paddingTop = getPaddingTop();
int paddingBottom = getPaddingBottom(); int paddingBottom = getPaddingBottom();
int verticalDividerLength = Math.max(0, getHeight() - paddingBottom - paddingTop); int verticalDividerLength = Math.max(0, getHeight() - paddingBottom - paddingTop);
...@@ -1017,14 +1015,15 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer { ...@@ -1017,14 +1015,15 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer {
// Draw horizontal dividers if needed // Draw horizontal dividers if needed
for (int j = 0; j < flexLine.mItemCount; j++) { for (int j = 0; j < flexLine.mItemCount; j++) {
View view = getReorderedChildAt(currentViewIndex); int viewIndex = flexLine.mFirstIndex + j;
View view = getReorderedChildAt(viewIndex);
if (view == null || view.getVisibility() == View.GONE) { if (view == null || view.getVisibility() == View.GONE) {
continue; continue;
} }
LayoutParams lp = (LayoutParams) view.getLayoutParams(); LayoutParams lp = (LayoutParams) view.getLayoutParams();
// Judge if the beginning or middle divider is needed // Judge if the beginning or middle divider is needed
if (hasDividerBeforeChildAtAlongMainAxis(currentViewIndex, j)) { if (hasDividerBeforeChildAtAlongMainAxis(viewIndex, j)) {
int dividerTop; int dividerTop;
if (fromBottomToTop) { if (fromBottomToTop) {
dividerTop = view.getBottom() + lp.bottomMargin; dividerTop = view.getBottom() + lp.bottomMargin;
...@@ -1049,7 +1048,6 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer { ...@@ -1049,7 +1048,6 @@ public class FlexboxLayout extends ViewGroup implements FlexContainer {
flexLine.mCrossSize); flexLine.mCrossSize);
} }
} }
currentViewIndex++;
} }
// Judge if the beginning or middle dividers are needed before the flex line // Judge if the beginning or middle dividers are needed before the flex line
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册