OnSwipe

public class OnSwipe
extends Object

java.lang.Object
   ↳ androidx.constraintlayout.motion.widget.OnSwipe


Container for holding swipe infomation

Summary

Constants

int COMPLETE_MODE_CONTINUOUS_VELOCITY

int COMPLETE_MODE_SPRING

int DRAG_ANTICLOCKWISE

int DRAG_CLOCKWISE

int DRAG_DOWN

int DRAG_END

int DRAG_LEFT

int DRAG_RIGHT

int DRAG_START

int DRAG_UP

int FLAG_DISABLE_POST_SCROLL

int FLAG_DISABLE_SCROLL

int ON_UP_AUTOCOMPLETE

int ON_UP_AUTOCOMPLETE_TO_END

int ON_UP_AUTOCOMPLETE_TO_START

int ON_UP_DECELERATE

int ON_UP_DECELERATE_AND_COMPLETE

int ON_UP_NEVER_TO_END

int ON_UP_NEVER_TO_START

int ON_UP_STOP

int SIDE_BOTTOM

int SIDE_END

int SIDE_LEFT

int SIDE_MIDDLE

int SIDE_RIGHT

int SIDE_START

int SIDE_TOP

int SPRING_BOUNDARY_BOUNCEBOTH

int SPRING_BOUNDARY_BOUNCEEND

int SPRING_BOUNDARY_BOUNCESTART

int SPRING_BOUNDARY_OVERSHOOT

Public constructors

OnSwipe()

Public methods

int getAutoCompleteMode()
int getDragDirection()
float getDragScale()
float getDragThreshold()
int getLimitBoundsTo()
float getMaxAcceleration()
float getMaxVelocity()
boolean getMoveWhenScrollAtTop()
int getNestedScrollFlags()
int getOnTouchUp()
int getRotationCenterId()
int getSpringBoundary()

The behaviour at the boundaries 0 and 1

float getSpringDamping()
float getSpringMass()

Get the mass of the spring.

float getSpringStiffness()

get the stiffness of the spring

float getSpringStopThreshold()

The threshold for spring motion to stop.

int getTouchAnchorId()
int getTouchAnchorSide()
int getTouchRegionId()
void setAutoCompleteMode(int autoCompleteMode)

sets the behaviour at the boundaries 0 and 1 COMPLETE_MODE_CONTINUOUS_VELOCITY = 0; COMPLETE_MODE_SPRING = 1;

OnSwipe setDragDirection(int dragDirection)

The direction of the drag.

OnSwipe setDragScale(int dragScale)

Normally 1 this can be tweaked to make the acceleration faster

OnSwipe setDragThreshold(int dragThreshold)

This sets the threshold before the animation is kicked off.

OnSwipe setLimitBoundsTo(int id)

Only allow touch actions to be initiated within this region

OnSwipe setMaxAcceleration(int maxAcceleration)

The maximum acceleration and deceleration of the animation (Change in Change in progress per second) Faster makes the object seem lighter and quicker

OnSwipe setMaxVelocity(int maxVelocity)

The maximum velocity (Change in progress per second) animation can achive

OnSwipe setMoveWhenScrollAtTop(boolean moveWhenScrollAtTop)

When collaborating with a NestedScrollView do you progress form 0-1 only when the scroll view is at the top.

OnSwipe setNestedScrollFlags(int flags)

Various flag to control behaviours of nested scroll FLAG_DISABLE_POST_SCROLL = 1; FLAG_DISABLE_SCROLL = 2;

OnSwipe setOnTouchUp(int mode)

Configures what happens when the user releases on mouse up.

OnSwipe setRotateCenter(int rotationCenterId)

The view to center the rotation about

OnSwipe setSpringBoundary(int springBoundary)

The behaviour at the boundaries 0 and 1.

OnSwipe setSpringDamping(float springDamping)

Set the damping of the spring if using spring.

OnSwipe setSpringMass(float springMass)

Set the Mass of the spring if using spring.

OnSwipe setSpringStiffness(float springStiffness)

set the stiffness of the spring if using spring.

OnSwipe setSpringStopThreshold(float springStopThreshold)

set the threshold for spring motion to stop.

OnSwipe setTouchAnchorId(int side)

The id of the view who's movement is matched to your drag If not specified it will map to a linear movement across the width of the motionLayout

OnSwipe setTouchAnchorSide(int side)

This side of the view that matches the drag movement.

OnSwipe setTouchRegionId(int side)

Inherited methods

Constants

COMPLETE_MODE_CONTINUOUS_VELOCITY

public static final int COMPLETE_MODE_CONTINUOUS_VELOCITY

Constant Value: 0 (0x00000000)

COMPLETE_MODE_SPRING

public static final int COMPLETE_MODE_SPRING

Constant Value: 1 (0x00000001)

DRAG_ANTICLOCKWISE

public static final int DRAG_ANTICLOCKWISE

Constant Value: 7 (0x00000007)

DRAG_CLOCKWISE

public static final int DRAG_CLOCKWISE

Constant Value: 6 (0x00000006)

DRAG_DOWN

public static final int DRAG_DOWN

Constant Value: 1 (0x00000001)

DRAG_END

public static final int DRAG_END

Constant Value: 5 (0x00000005)

DRAG_LEFT

public static final int DRAG_LEFT

Constant Value: 2 (0x00000002)

DRAG_RIGHT

public static final int DRAG_RIGHT

Constant Value: 3 (0x00000003)

DRAG_START

public static final int DRAG_START

Constant Value: 4 (0x00000004)

DRAG_UP

public static final int DRAG_UP

Constant Value: 0 (0x00000000)

FLAG_DISABLE_POST_SCROLL

public static final int FLAG_DISABLE_POST_SCROLL

Constant Value: 1 (0x00000001)

FLAG_DISABLE_SCROLL

public static final int FLAG_DISABLE_SCROLL

Constant Value: 2 (0x00000002)

ON_UP_AUTOCOMPLETE

public static final int ON_UP_AUTOCOMPLETE

Constant Value: 0 (0x00000000)

ON_UP_AUTOCOMPLETE_TO_END

public static final int ON_UP_AUTOCOMPLETE_TO_END

Constant Value: 2 (0x00000002)

ON_UP_AUTOCOMPLETE_TO_START

public static final int ON_UP_AUTOCOMPLETE_TO_START

Constant Value: 1 (0x00000001)

ON_UP_DECELERATE

public static final int ON_UP_DECELERATE

Constant Value: 4 (0x00000004)

ON_UP_DECELERATE_AND_COMPLETE

public static final int ON_UP_DECELERATE_AND_COMPLETE

Constant Value: 5 (0x00000005)

ON_UP_NEVER_TO_END

public static final int ON_UP_NEVER_TO_END

Constant Value: 7 (0x00000007)

ON_UP_NEVER_TO_START

public static final int ON_UP_NEVER_TO_START

Constant Value: 6 (0x00000006)

ON_UP_STOP

public static final int ON_UP_STOP

Constant Value: 3 (0x00000003)

SIDE_BOTTOM

public static final int SIDE_BOTTOM

Constant Value: 3 (0x00000003)

SIDE_END

public static final int SIDE_END

Constant Value: 6 (0x00000006)

SIDE_LEFT

public static final int SIDE_LEFT

Constant Value: 1 (0x00000001)

SIDE_MIDDLE

public static final int SIDE_MIDDLE

Constant Value: 4 (0x00000004)

SIDE_RIGHT

public static final int SIDE_RIGHT

Constant Value: 2 (0x00000002)

SIDE_START

public static final int SIDE_START

Constant Value: 5 (0x00000005)

SIDE_TOP

public static final int SIDE_TOP

Constant Value: 0 (0x00000000)

SPRING_BOUNDARY_BOUNCEBOTH

public static final int SPRING_BOUNDARY_BOUNCEBOTH

Constant Value: 3 (0x00000003)

SPRING_BOUNDARY_BOUNCEEND

public static final int SPRING_BOUNDARY_BOUNCEEND

Constant Value: 2 (0x00000002)

SPRING_BOUNDARY_BOUNCESTART

public static final int SPRING_BOUNDARY_BOUNCESTART

Constant Value: 1 (0x00000001)

SPRING_BOUNDARY_OVERSHOOT

public static final int SPRING_BOUNDARY_OVERSHOOT

Constant Value: 0 (0x00000000)

Public constructors

OnSwipe

public OnSwipe ()

Public methods

getAutoCompleteMode

public int getAutoCompleteMode ()

Returns
int

getDragDirection

public int getDragDirection ()

Returns
int

getDragScale

public float getDragScale ()

Returns
float

getDragThreshold

public float getDragThreshold ()

Returns
float

getLimitBoundsTo

public int getLimitBoundsTo ()

Returns
int

getMaxAcceleration

public float getMaxAcceleration ()

Returns
float

getMaxVelocity

public float getMaxVelocity ()

Returns
float

getMoveWhenScrollAtTop

public boolean getMoveWhenScrollAtTop ()

Returns
boolean

getNestedScrollFlags

public int getNestedScrollFlags ()

Returns
int

getOnTouchUp

public int getOnTouchUp ()

Returns
int

getRotationCenterId

public int getRotationCenterId ()

Returns
int

getSpringBoundary

public int getSpringBoundary ()

The behaviour at the boundaries 0 and 1

Returns
int

getSpringDamping

public float getSpringDamping ()

Returns
float

getSpringMass

public float getSpringMass ()

Get the mass of the spring. the m in "a = (-k*x-c*v)/m" equation for the acceleration of a spring

Returns
float

getSpringStiffness

public float getSpringStiffness ()

get the stiffness of the spring

Returns
float NaN if not set

getSpringStopThreshold

public float getSpringStopThreshold ()

The threshold for spring motion to stop.

Returns
float

getTouchAnchorId

public int getTouchAnchorId ()

Returns
int

getTouchAnchorSide

public int getTouchAnchorSide ()

Returns
int

getTouchRegionId

public int getTouchRegionId ()

Returns
int

setAutoCompleteMode

public void setAutoCompleteMode (int autoCompleteMode)

sets the behaviour at the boundaries 0 and 1 COMPLETE_MODE_CONTINUOUS_VELOCITY = 0; COMPLETE_MODE_SPRING = 1;

Parameters
autoCompleteMode int

setDragDirection

public OnSwipe setDragDirection (int dragDirection)

The direction of the drag.

Returns
OnSwipe

setDragScale

public OnSwipe setDragScale (int dragScale)

Normally 1 this can be tweaked to make the acceleration faster

Returns
OnSwipe

setDragThreshold

public OnSwipe setDragThreshold (int dragThreshold)

This sets the threshold before the animation is kicked off. It is important when have multi state animations the have some play before the System decides which animation to jump on.

Returns
OnSwipe

setLimitBoundsTo

public OnSwipe setLimitBoundsTo (int id)

Only allow touch actions to be initiated within this region

Returns
OnSwipe

setMaxAcceleration

public OnSwipe setMaxAcceleration (int maxAcceleration)

The maximum acceleration and deceleration of the animation (Change in Change in progress per second) Faster makes the object seem lighter and quicker

Returns
OnSwipe

setMaxVelocity

public OnSwipe setMaxVelocity (int maxVelocity)

The maximum velocity (Change in progress per second) animation can achive

Returns
OnSwipe

setMoveWhenScrollAtTop

public OnSwipe setMoveWhenScrollAtTop (boolean moveWhenScrollAtTop)

When collaborating with a NestedScrollView do you progress form 0-1 only when the scroll view is at the top.

Returns
OnSwipe

setNestedScrollFlags

public OnSwipe setNestedScrollFlags (int flags)

Various flag to control behaviours of nested scroll FLAG_DISABLE_POST_SCROLL = 1; FLAG_DISABLE_SCROLL = 2;

Returns
OnSwipe

setOnTouchUp

public OnSwipe setOnTouchUp (int mode)

Configures what happens when the user releases on mouse up. One of: ON_UP_AUTOCOMPLETE, ON_UP_AUTOCOMPLETE_TO_START, ON_UP_AUTOCOMPLETE_TO_END, ON_UP_STOP, ON_UP_DECELERATE, ON_UP_DECELERATE_AND_COMPLETE

Parameters
mode int: default = ON_UP_AUTOCOMPLETE

Returns
OnSwipe

setRotateCenter

public OnSwipe setRotateCenter (int rotationCenterId)

The view to center the rotation about

Returns
OnSwipe this

setSpringBoundary

public OnSwipe setSpringBoundary (int springBoundary)

The behaviour at the boundaries 0 and 1. SPRING_BOUNDARY_OVERSHOOT = 0; SPRING_BOUNDARY_BOUNCE_START = 1; SPRING_BOUNDARY_BOUNCE_END = 2; SPRING_BOUNDARY_BOUNCE_BOTH = 3;

Returns
OnSwipe

setSpringDamping

public OnSwipe setSpringDamping (float springDamping)

Set the damping of the spring if using spring. c in "a = (-k*x-c*v)/m" equation for the acceleration of a spring

Returns
OnSwipe this

setSpringMass

public OnSwipe setSpringMass (float springMass)

Set the Mass of the spring if using spring. m in "a = (-k*x-c*v)/m" equation for the acceleration of a spring

Returns
OnSwipe this

setSpringStiffness

public OnSwipe setSpringStiffness (float springStiffness)

set the stiffness of the spring if using spring. If this is set the swipe will use a spring return system. If set to NaN it will revert to the norm system. K in "a = (-k*x-c*v)/m" equation for the acceleration of a spring

Returns
OnSwipe

setSpringStopThreshold

public OnSwipe setSpringStopThreshold (float springStopThreshold)

set the threshold for spring motion to stop. This is in change in progress / second If the spring will never go above that threshold again it will stop.

Returns
OnSwipe

setTouchAnchorId

public OnSwipe setTouchAnchorId (int side)

The id of the view who's movement is matched to your drag If not specified it will map to a linear movement across the width of the motionLayout

Returns
OnSwipe

setTouchAnchorSide

public OnSwipe setTouchAnchorSide (int side)

This side of the view that matches the drag movement. Only meaning full if the object changes size during the movement. (rotation is not considered)

Returns
OnSwipe

setTouchRegionId

public OnSwipe setTouchRegionId (int side)

Returns
OnSwipe