Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3701d65 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Extract resolveSwipeSource() and resolveSwipe()" into main

parents 2e54345c 1e34a1df
Loading
Loading
Loading
Loading
+39 −30
Original line number Original line Diff line number Diff line
@@ -188,38 +188,47 @@ internal class DraggableHandlerImpl(
        return createSwipeAnimation(layoutImpl, result, isUpOrLeft, orientation)
        return createSwipeAnimation(layoutImpl, result, isUpOrLeft, orientation)
    }
    }


    private fun computeSwipes(startedPosition: Offset?, pointersDown: Int): Swipes {
    private fun resolveSwipeSource(startedPosition: Offset?): SwipeSource.Resolved? {
        val fromSource =
        if (startedPosition == null) return null
            startedPosition?.let { position ->
        return layoutImpl.swipeSourceDetector.source(
                layoutImpl.swipeSourceDetector.source(
            layoutSize = layoutImpl.lastSize,
                    layoutImpl.lastSize,
            position = startedPosition.round(),
                    position.round(),
            density = layoutImpl.density,
                    layoutImpl.density,
            orientation = orientation,
                    orientation,
        )
        )
    }
    }


        val upOrLeft =
    private fun resolveSwipe(
            Swipe.Resolved(
        pointersDown: Int,
        fromSource: SwipeSource.Resolved?,
        isUpOrLeft: Boolean,
    ): Swipe.Resolved {
        return Swipe.Resolved(
            direction =
            direction =
                when (orientation) {
                when (orientation) {
                        Orientation.Horizontal -> SwipeDirection.Resolved.Left
                    Orientation.Horizontal ->
                        Orientation.Vertical -> SwipeDirection.Resolved.Up
                        if (isUpOrLeft) {
                    },
                            SwipeDirection.Resolved.Left
                pointerCount = pointersDown,
                        } else {
                fromSource = fromSource,
                            SwipeDirection.Resolved.Right
            )
                        }


        val downOrRight =
                    Orientation.Vertical ->
            Swipe.Resolved(
                        if (isUpOrLeft) {
                direction =
                            SwipeDirection.Resolved.Up
                    when (orientation) {
                        } else {
                        Orientation.Horizontal -> SwipeDirection.Resolved.Right
                            SwipeDirection.Resolved.Down
                        Orientation.Vertical -> SwipeDirection.Resolved.Down
                        }
                },
                },
            pointerCount = pointersDown,
            pointerCount = pointersDown,
            fromSource = fromSource,
            fromSource = fromSource,
        )
        )
    }

    private fun computeSwipes(startedPosition: Offset?, pointersDown: Int): Swipes {
        val fromSource = resolveSwipeSource(startedPosition)
        val upOrLeft = resolveSwipe(pointersDown, fromSource, isUpOrLeft = true)
        val downOrRight = resolveSwipe(pointersDown, fromSource, isUpOrLeft = false)


        return if (fromSource == null) {
        return if (fromSource == null) {
            Swipes(
            Swipes(