Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
fix startSpace and endSpace error when layout from end to start
Browse files Browse the repository at this point in the history
  • Loading branch information
longerian committed Jan 7, 2018
1 parent 1538395 commit e68722d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1739,11 +1739,22 @@ public void assignFromView(View child) {
if (mLayoutFromEnd) {
mCoordinate = mOrientationHelper.getDecoratedEnd(child) + computeAlignOffset(child, mLayoutFromEnd, true) +
mOrientationHelper.getTotalSpaceChange();
if (DEBUG) {
Log.d(TAG, "1 mLayoutFromEnd " + mLayoutFromEnd + " mOrientationHelper.getDecoratedEnd(child) "
+ mOrientationHelper.getDecoratedEnd(child) + " computeAlignOffset(child, mLayoutFromEnd, true) " + computeAlignOffset(child, mLayoutFromEnd, true));
}
} else {
mCoordinate = mOrientationHelper.getDecoratedStart(child) + computeAlignOffset(child, mLayoutFromEnd, true);
if (DEBUG) {
Log.d(TAG, "2 mLayoutFromEnd " + mLayoutFromEnd + " mOrientationHelper.getDecoratedStart(child) "
+ mOrientationHelper.getDecoratedStart(child) + " computeAlignOffset(child, mLayoutFromEnd, true) " + computeAlignOffset(child, mLayoutFromEnd, true));
}
}

mPosition = getPosition(child);
if (DEBUG) {
Log.d(TAG, "position " + mPosition + " mCoordinate " + mCoordinate);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,12 @@ protected int computeStartSpace(LayoutManagerHelper helper, boolean layoutInVert
return 0;

if (!isOverLapMargin) {
startSpace = layoutInVertical
? (isLayoutEnd ? mMarginTop + mPaddingTop : mMarginBottom + mPaddingBottom)
: (isLayoutEnd ? mMarginLeft + mPaddingLeft : mMarginRight + mPaddingRight);
startSpace = layoutInVertical ? mMarginTop + mPaddingTop : mMarginLeft + mPaddingLeft;
} else {
int offset = 0;

if (lastMarginLayoutHelper == null) {
offset = layoutInVertical
? (isLayoutEnd ? mMarginTop + mPaddingTop : mMarginBottom + mPaddingBottom)
: (isLayoutEnd ? mMarginLeft + mPaddingLeft : mMarginRight + mPaddingRight);
offset = layoutInVertical ? mMarginTop + mPaddingTop : mMarginLeft + mPaddingLeft;
} else {
offset = layoutInVertical
? (isLayoutEnd ? calGap(lastMarginLayoutHelper.mMarginBottom, mMarginTop) : calGap(lastMarginLayoutHelper.mMarginTop, mMarginBottom))
Expand All @@ -576,8 +572,7 @@ protected int computeStartSpace(LayoutManagerHelper helper, boolean layoutInVert

protected int computeEndSpace(LayoutManagerHelper helper, boolean layoutInVertical, boolean isLayoutEnd, boolean isOverLapMargin) {
int endSpace = layoutInVertical
? (isLayoutEnd ? mMarginBottom + mPaddingBottom : mMarginTop + mPaddingTop)
: (isLayoutEnd ? mMarginRight + mPaddingRight : mMarginLeft + mPaddingLeft);
? mMarginBottom + mPaddingBottom : mMarginLeft + mPaddingLeft;
//Log.e("huang", "computeEndSpace offset: " + endSpace + ", isLayoutEnd: " + isLayoutEnd + ", " + this);
//Log.e("huang", "===================\n\n");
return endSpace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ public static int computeStartAlignOffset(GridRangeStyle rangeStyle, boolean lay
for (int i = 0, size = rangeStyle.mChildren.size(); i < size; i++) {
GridRangeStyle childRangeStyle = rangeStyle.mChildren.valueAt(i);
if (!childRangeStyle.isChildrenEmpty()){
//FIXEME may compute the wrong start space here
//FIXME may compute the wrong start space here
offset += computeStartAlignOffset(childRangeStyle, layoutInVertical);
}else if (childRangeStyle.mRange.getLower().intValue() == startPosition) {
offset += (layoutInVertical ? -childRangeStyle.mMarginTop - childRangeStyle.mPaddingTop
Expand Down

0 comments on commit e68722d

Please sign in to comment.