Skip to content

Commit 33656ed

Browse files
committed
Do not render edge effects when View.OVER_SCROLL_NEVER has been specified while dragging (issue h6ah4i#374)
1 parent 096a9b5 commit 33656ed

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

library/src/main/java/com/h6ah4i/android/widget/advrecyclerview/draggable/RecyclerViewDragDropManager.java

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,36 +1372,37 @@ private void handleScrollOnDraggingInternalWithRecyclerView(RecyclerView rv, boo
13721372
decorator.setIsScrolling(false);
13731373
}
13741374

1375-
final boolean actualIsScrolling = (actualScrolledAmount != 0);
1376-
1377-
13781375
if (mEdgeEffectDecorator != null) {
1379-
final float edgeEffectStrength = 0.005f;
1380-
1381-
final int draggingItemTopLeft = (horizontal) ? decorator.getTranslatedItemPositionLeft() : decorator.getTranslatedItemPositionTop();
1382-
final int draggingItemBottomRight = (horizontal) ? decorator.getTranslatedItemPositionRight() : decorator.getTranslatedItemPositionBottom();
1383-
final int draggingItemCenter = (draggingItemTopLeft + draggingItemBottomRight) / 2;
1384-
final int nearEdgePosition;
1376+
float edgeEffectPullDistance = 0;
13851377

1386-
if (firstVisibleChild == 0 && lastVisibleChild == 0) {
1387-
// has only 1 item
1388-
nearEdgePosition = (scrollAmount < 0) ? draggingItemTopLeft : draggingItemBottomRight;
1389-
} else {
1390-
nearEdgePosition = (draggingItemCenter < (edge / 2)) ? draggingItemTopLeft : draggingItemBottomRight;
1391-
}
1378+
if (mOrigOverScrollMode != View.OVER_SCROLL_NEVER) {
1379+
final boolean actualIsScrolling = (actualScrolledAmount != 0);
1380+
final float edgeEffectStrength = 0.005f;
13921381

1393-
final float nearEdgeOffset = (nearEdgePosition * invEdge) - 0.5f;
1394-
final float absNearEdgeOffset = Math.abs(nearEdgeOffset);
1395-
float edgeEffectPullDistance = 0;
1382+
final int draggingItemTopLeft = (horizontal) ? decorator.getTranslatedItemPositionLeft() : decorator.getTranslatedItemPositionTop();
1383+
final int draggingItemBottomRight = (horizontal) ? decorator.getTranslatedItemPositionRight() : decorator.getTranslatedItemPositionBottom();
1384+
final int draggingItemCenter = (draggingItemTopLeft + draggingItemBottomRight) / 2;
1385+
final int nearEdgePosition;
13961386

1397-
if ((absNearEdgeOffset > 0.4f) && (scrollAmount != 0) && !actualIsScrolling) {
1398-
if (nearEdgeOffset < 0) {
1399-
if (horizontal ? decorator.isReachedToLeftLimit() : decorator.isReachedToTopLimit()) {
1400-
edgeEffectPullDistance = -mDisplayDensity * edgeEffectStrength;
1401-
}
1387+
if (firstVisibleChild == 0 && lastVisibleChild == 0) {
1388+
// has only 1 item
1389+
nearEdgePosition = (scrollAmount < 0) ? draggingItemTopLeft : draggingItemBottomRight;
14021390
} else {
1403-
if (horizontal ? decorator.isReachedToRightLimit() : decorator.isReachedToBottomLimit()) {
1404-
edgeEffectPullDistance = mDisplayDensity * edgeEffectStrength;
1391+
nearEdgePosition = (draggingItemCenter < (edge / 2)) ? draggingItemTopLeft : draggingItemBottomRight;
1392+
}
1393+
1394+
final float nearEdgeOffset = (nearEdgePosition * invEdge) - 0.5f;
1395+
final float absNearEdgeOffset = Math.abs(nearEdgeOffset);
1396+
1397+
if ((absNearEdgeOffset > 0.4f) && (scrollAmount != 0) && !actualIsScrolling) {
1398+
if (nearEdgeOffset < 0) {
1399+
if (horizontal ? decorator.isReachedToLeftLimit() : decorator.isReachedToTopLimit()) {
1400+
edgeEffectPullDistance = -mDisplayDensity * edgeEffectStrength;
1401+
}
1402+
} else {
1403+
if (horizontal ? decorator.isReachedToRightLimit() : decorator.isReachedToBottomLimit()) {
1404+
edgeEffectPullDistance = mDisplayDensity * edgeEffectStrength;
1405+
}
14051406
}
14061407
}
14071408
}

0 commit comments

Comments
 (0)