Skip to content
This repository was archived by the owner on Dec 8, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,6 @@ public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State
}

measureChildWithMargins(scrap, 0, 0);
mDecoratedMeasurement = mOrientationHelper.getDecoratedMeasurement(scrap);
mDecoratedMeasurementInOther = mOrientationHelper.getDecoratedMeasurementInOther(scrap);
mSpaceMain = (mOrientationHelper.getTotalSpace() - mDecoratedMeasurement) / 2;
if (mDistanceToBottom == INVALID_SIZE) {
mSpaceInOther = (mOrientationHelper.getTotalSpaceInOther() - mDecoratedMeasurementInOther) / 2;
} else {
mSpaceInOther = mOrientationHelper.getTotalSpaceInOther() - mDecoratedMeasurementInOther - mDistanceToBottom;
}

mInterval = setInterval();
setUp();
Expand All @@ -416,6 +408,17 @@ public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State
layoutItems(recycler);
}

private void calChildSpaceAndSpace(View scrap) {
mDecoratedMeasurement = mOrientationHelper.getDecoratedMeasurement(scrap);
mDecoratedMeasurementInOther = mOrientationHelper.getDecoratedMeasurementInOther(scrap);
mSpaceMain = (mOrientationHelper.getTotalSpace() - mDecoratedMeasurement) / 2;
if (mDistanceToBottom == INVALID_SIZE) {
mSpaceInOther = (mOrientationHelper.getTotalSpaceInOther() - mDecoratedMeasurementInOther) / 2;
} else {
mSpaceInOther = mOrientationHelper.getTotalSpaceInOther() - mDecoratedMeasurementInOther - mDistanceToBottom;
}
}

private View getMeasureView(RecyclerView.Recycler recycler, RecyclerView.State state, int index) {
if (index >= state.getItemCount() || index < 0) return null;
try {
Expand Down Expand Up @@ -718,6 +721,7 @@ private void resetViewProperty(View v) {
private void layoutScrap(View scrap, float targetOffset) {
final int left = calItemLeft(scrap, targetOffset);
final int top = calItemTop(scrap, targetOffset);
calChildSpaceAndSpace(scrap);
if (mOrientation == VERTICAL) {
layoutDecorated(scrap, mSpaceInOther + left, mSpaceMain + top,
mSpaceInOther + left + mDecoratedMeasurementInOther, mSpaceMain + top + mDecoratedMeasurement);
Expand Down