Constantly set elevation during drag in case of update

Clean code at drag start
drag-tabs
Steven Knipe 3 years ago
parent d36497166b
commit c72675e620

@ -242,16 +242,12 @@ abstract class AbstractBrowserTabViewHolder(
if (parent?.context?.settings()?.searchTermTabGroupsAreEnabled == false &&
holder.selectedItems.contains(item) && holder.selectedItems.size == 1
) {
for (tabSelected in holder.selectedItems) {
// Exit selection mode by deselecting everything
interactor.deselect(tabSelected)
}
interactor.deselect(item) // Exit selection mode
val shadow = BlankDragShadowBuilder()
beingDragged = true
val point = PointF(motionEvent.x, motionEvent.y)
val dragOffset = PointF(motionEvent.x, motionEvent.y)
// startDragAndDrop is the non-deprecated version, but requires API 24
@Suppress("DEPRECATION")
view.startDrag(null, shadow, TabDragData(item, point), 0)
view.startDrag(null, shadow, TabDragData(item, dragOffset), 0)
} else view.onTouchEvent(motionEvent)
}
else -> view.onTouchEvent(motionEvent)

@ -106,8 +106,9 @@ abstract class AbstractBrowserTrayList @JvmOverloads constructor(
DragEvent.ACTION_DRAG_STARTED -> {
// Put the dragged tab on top of all other tabs
if (sources != null) {
val (sourceView, _) = sources
sourceView.elevation += DRAGGED_TAB_ELEVATION
val (sourceView, sourceViewHolder) = sources
sourceViewHolder.beingDragged = true
sourceView.elevation = DRAGGED_TAB_ELEVATION
}
// Setup the scrolling/updating loop
lastDragPos = PointF(event.x, event.y)
@ -132,12 +133,11 @@ abstract class AbstractBrowserTrayList @JvmOverloads constructor(
// Move tab to center, set dragging to false, return tab to normal height
if (sources != null) {
val (sourceView, sourceViewHolder) = sources
sourceView.elevation -= DRAGGED_TAB_ELEVATION
sourceViewHolder.beingDragged = false
sourceView.elevation = 0f
sourceView.animate()
.translationX(0f).translationY(0f).duration =
itemAnimator?.moveDuration ?: 0
sourceViewHolder.beingDragged = false
}
// This will stop the scroll/update loop
lastDragPos = null
@ -165,6 +165,7 @@ abstract class AbstractBrowserTrayList @JvmOverloads constructor(
sourceView.x = pos.x - dragOffset.x
sourceView.y = pos.y - dragOffset.y
sourceViewHolder.beingDragged = true
sourceView.elevation = DRAGGED_TAB_ELEVATION
// Move the tab's position in the list
val target = getDropPosition(pos.x, pos.y, tab.id)

Loading…
Cancel
Save