BackEventCompat
public final class BackEventCompat
Compat around the BackEvent class
Summary
Constants |
|
|---|---|
static final int |
EDGE_LEFT = 0Indicates that the edge swipe starts from the left edge of the screen |
static final int |
EDGE_NONE = 2Indicates that the back event was not triggered by an edge swipe back gesture. |
static final int |
EDGE_RIGHT = 1Indicates that the edge swipe starts from the right edge of the screen |
Public constructors |
|---|
@RequiresApi(value = 34)Constructs a |
BackEventCompat(@NonNull NavigationEvent navigationEvent)Constructs a |
@VisibleForTesting |
Public methods |
|
|---|---|
final long |
Frame time of the back event. |
final float |
Value between 0 and 1 on how far along the back gesture is. |
final int |
Indicates which edge the swipe starts from. |
final float |
Absolute X location of the touch point of this event in the coordinate space of the view that |
final float |
Absolute Y location of the touch point of this event in the coordinate space of the view that received this back event. |
final @NonNull BackEvent |
@RequiresApi(value = 34)Convert this |
final @NonNull NavigationEvent |
Convert this |
@NonNull String |
toString() |
Constants
EDGE_LEFT
public static final int EDGE_LEFT = 0
Indicates that the edge swipe starts from the left edge of the screen
EDGE_NONE
public static final int EDGE_NONE = 2
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.
EDGE_RIGHT
public static final int EDGE_RIGHT = 1
Indicates that the edge swipe starts from the right edge of the screen
Public constructors
BackEventCompat
@RequiresApi(value = 34)
public BackEventCompat(@NonNull BackEvent backEvent)
Constructs a BackEventCompat from a BackEvent object.
This constructor is used for API level 34 and above, mapping the BackEvent's properties to the corresponding values in BackEventCompat.
BackEventCompat
public BackEventCompat(@NonNull NavigationEvent navigationEvent)
Constructs a BackEventCompat from a NavigationEvent object.
This constructor is used for compatibility with NavigationEvent and maps its properties to the corresponding values in BackEventCompat.
| Parameters | |
|---|---|
@NonNull NavigationEvent navigationEvent |
The |
BackEventCompat
@VisibleForTesting
public BackEventCompat(
float touchX,
float touchY,
@FloatRange(from = 0.0, to = 1.0) float progress,
int swipeEdge,
long frameTimeMillis
)
Public methods
getFrameTimeMillis
public final long getFrameTimeMillis()
Frame time of the back event.
getProgress
public final float getProgress()
Value between 0 and 1 on how far along the back gesture is.
getSwipeEdge
public final int getSwipeEdge()
Indicates which edge the swipe starts from.
getTouchX
public final float getTouchX()
Absolute X location of the touch point of this event in the coordinate space of the view that
-
received this back event.
getTouchY
public final float getTouchY()
Absolute Y location of the touch point of this event in the coordinate space of the view that received this back event.
toBackEvent
@RequiresApi(value = 34)
public final @NonNull BackEvent toBackEvent()
Convert this BackEventCompat object to a BackEvent object.
| Returns | |
|---|---|
@NonNull BackEvent |
A new |
| Throws | |
|---|---|
kotlin.UnsupportedOperationException |
if this API is called on an API prior to 34. |
toNavigationEvent
public final @NonNull NavigationEvent toNavigationEvent()
Convert this BackEventCompat object to a NavigationEvent object.
| Returns | |
|---|---|
@NonNull NavigationEvent |
A new |