BackEvent
class BackEvent
kotlin.Any | |
↳ | android.window.BackEvent |
Object used to report back gesture progress. Holds information about the touch event, swipe direction and the animation progress that predictive back animations should seek to.
Summary
Constants | |
---|---|
static Int |
Indicates that the edge swipe starts from the left edge of the screen |
static Int |
Indicates that the back event was not triggered by an edge swipe back gesture. |
static Int |
Indicates that the edge swipe starts from the right edge of the screen |
Public constructors | |
---|---|
Creates a new |
|
Creates a new |
Public methods | |
---|---|
Boolean | |
Long |
Returns the frameTime of the BackEvent in milliseconds. |
Float |
Returns a value between 0 and 1 on how far along the back gesture is. |
Int |
Returns the screen edge that the swipe starts from. |
Float |
Returns the absolute X location of the touch point, or NaN if the event is from a button press. |
Float |
Returns the absolute Y location of the touch point, or NaN if the event is from a button press. |
String |
toString() |
Constants
EDGE_LEFT
static val EDGE_LEFT: Int
Indicates that the edge swipe starts from the left edge of the screen
Value: 0
EDGE_NONE
static val EDGE_NONE: Int
Indicates that the back event was not triggered by an edge swipe back gesture. This applies to cases like using the back button in 3-button navigation or pressing a hardware back button.
Value: 2
EDGE_RIGHT
static val EDGE_RIGHT: Int
Indicates that the edge swipe starts from the right edge of the screen
Value: 1
Public constructors
BackEvent
BackEvent(
touchX: Float,
touchY: Float,
progress: Float,
swipeEdge: Int)
Creates a new BackEvent
instance with a frame time of 0.
Parameters | |
---|---|
touchX |
Float: Absolute X location of the touch point of this event. |
touchY |
Float: Absolute Y location of the touch point of this event. |
progress |
Float: Value between 0 and 1 on how far along the back gesture is. |
swipeEdge |
Int: Indicates which edge the swipe starts from. Value is android.window.BackEvent#EDGE_LEFT , android.window.BackEvent#EDGE_RIGHT , or android.window.BackEvent#EDGE_NONE |
BackEvent
BackEvent(
touchX: Float,
touchY: Float,
progress: Float,
swipeEdge: Int,
frameTimeMillis: Long)
Creates a new BackEvent
instance.
Parameters | |
---|---|
touchX |
Float: Absolute X location of the touch point of this event. |
touchY |
Float: Absolute Y location of the touch point of this event. |
progress |
Float: Value between 0 and 1 on how far along the back gesture is. |
swipeEdge |
Int: Indicates which edge the swipe starts from. Value is android.window.BackEvent#EDGE_LEFT , android.window.BackEvent#EDGE_RIGHT , or android.window.BackEvent#EDGE_NONE |
frameTimeMillis |
Long: frame time of the back event. |
Public methods
equals
fun equals(other: Any?): Boolean
Parameters | |
---|---|
obj |
the reference object with which to compare. |
Return | |
---|---|
Boolean |
true if this object is the same as the obj argument; false otherwise. |
getFrameTimeMillis
fun getFrameTimeMillis(): Long
Returns the frameTime of the BackEvent in milliseconds. Useful for calculating velocity.
getProgress
fun getProgress(): Float
Returns a value between 0 and 1 on how far along the back gesture is. This value is driven by the horizontal location of the touch point, and should be used as the fraction to seek the predictive back animation with. Specifically,
- The progress is 0 when the touch is at the starting edge of the screen (left or right), and animation should seek to its start state.
- The progress is approximately 1 when the touch is at the opposite side of the screen, and animation should seek to its end state. Exact end value may vary depending on screen size.
Return | |
---|---|
Float |
Value is between 0 and 1 inclusive |
getSwipeEdge
fun getSwipeEdge(): Int
Returns the screen edge that the swipe starts from.
Return | |
---|---|
Int |
Value is android.window.BackEvent#EDGE_LEFT , android.window.BackEvent#EDGE_RIGHT , or android.window.BackEvent#EDGE_NONE |
getTouchX
fun getTouchX(): Float
Returns the absolute X location of the touch point, or NaN if the event is from a button press.
getTouchY
fun getTouchY(): Float
Returns the absolute Y location of the touch point, or NaN if the event is from a button press.
toString
fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |