Skip to content

Commit 3ecb01a

Browse files
committed
Merge pull request #8 from edwardaa/remove-and-restore-LayoutTransition
Fix animation conflicts with LayoutTransition
2 parents 896ce9e + df6bec2 commit 3ecb01a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/src/main/java/com/jmedeisis/draglinearlayout/DragLinearLayout.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public interface OnViewSwapListener {
6161

6262
private OnViewSwapListener swapListener;
6363

64+
private LayoutTransition layoutTransition;
65+
6466
/**
6567
* Mapping from child index to drag-related info container.
6668
* Presence of mapping implies the child can be dragged, and is considered for swaps with the
@@ -357,6 +359,13 @@ private void startDetectingDrag(View child) {
357359
}
358360

359361
private void startDrag() {
362+
// remove layout transition, it conflicts with drag animation
363+
// we will restore it after drag animation end, see stopDrag()
364+
layoutTransition = getLayoutTransition();
365+
if (layoutTransition != null) {
366+
setLayoutTransition(null);
367+
}
368+
360369
draggedItem.onDragStart();
361370
requestDisallowInterceptTouchEvent(true);
362371
}
@@ -398,6 +407,11 @@ public void onAnimationEnd(Animator animation) {
398407

399408
if (null != dragTopShadowDrawable) dragTopShadowDrawable.setAlpha(255);
400409
dragBottomShadowDrawable.setAlpha(255);
410+
411+
// restore layout transition
412+
if (layoutTransition != null && getLayoutTransition() == null) {
413+
setLayoutTransition(layoutTransition);
414+
}
401415
}
402416
});
403417
draggedItem.settleAnimation.start();

0 commit comments

Comments
 (0)