Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复滑动多选时从底部往上滑选中顺序错误 #2888

Open
wants to merge 1 commit into
base: version_component
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -307,6 +307,8 @@ private void notifySelectRangeChange() {
return;
}

boolean isReverse = mStart > mEnd;

int newStart, newEnd;
newStart = Math.min(mStart, mEnd);
newEnd = Math.max(mStart, mEnd);
Expand All @@ -315,21 +317,21 @@ private void notifySelectRangeChange() {
}
if (mLastStart == RecyclerView.NO_POSITION || mLastEnd == RecyclerView.NO_POSITION) {
if (newEnd - newStart == 1) {
mSelectListener.onSelectChange(newStart, newStart, true);
mSelectListener.onSelectChange(newStart, newStart, true, isReverse);
} else {
mSelectListener.onSelectChange(newStart, newEnd, true);
mSelectListener.onSelectChange(newStart, newEnd, true, isReverse);
}
} else {
if (newStart > mLastStart) {
mSelectListener.onSelectChange(mLastStart, newStart - 1, false);
mSelectListener.onSelectChange(mLastStart, newStart - 1, false, isReverse);
} else if (newStart < mLastStart) {
mSelectListener.onSelectChange(newStart, mLastStart - 1, true);
mSelectListener.onSelectChange(newStart, mLastStart - 1, true, isReverse);
}

if (newEnd > mLastEnd) {
mSelectListener.onSelectChange(mLastEnd + 1, newEnd, true);
mSelectListener.onSelectChange(mLastEnd + 1, newEnd, true, isReverse);
} else if (newEnd < mLastEnd) {
mSelectListener.onSelectChange(newEnd + 1, mLastEnd, false);
mSelectListener.onSelectChange(newEnd + 1, mLastEnd, false, isReverse);
}
}

Expand Down Expand Up @@ -389,7 +391,8 @@ public interface OnSlideSelectListener {
* @param start the newly (un)selected range start
* @param end the newly (un)selected range end
* @param isSelected true, it range got selected, false if not
* @param isReverse true, it select from bottom to top, false if not
*/
void onSelectChange(int start, int end, boolean isSelected);
void onSelectChange(int start, int end, boolean isSelected, boolean isReverse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@ public void onSelectionFinished(int end) {
}

@Override
public void onSelectChange(int start, int end, boolean isSelected) {
for (int i = start; i <= end; i++) {
checkedChangeSelection(i, i, isSelected != mOriginalSelection.contains(i));
public void onSelectChange(int start, int end, boolean isSelected, boolean isReverse) {
if (isReverse) {
for (int i = end; i >= start; i--) {
checkedChangeSelection(i, i, isSelected != mOriginalSelection.contains(i));
}
}
else {
for (int i = start; i <= end; i++) {
checkedChangeSelection(i, i, isSelected != mOriginalSelection.contains(i));
}
}
}

Expand Down