SurfaceCallback
interface SurfaceCallback
A callback for changes on the SurfaceContainer and its attributes.
Summary
Public functions |
|
|---|---|
Unit |
@RequiresCarApi(value = 5)Provides information about a click event on the car screen. |
Unit |
@RequiresCarApi(value = 2)Provides information about a fling touch event on the car screen. |
Unit |
@RequiresCarApi(value = 2)Provides information about a scale touch event on the car screen. |
Unit |
@RequiresCarApi(value = 2)Provides information about a scroll touch event on the car screen. |
Unit |
onStableAreaChanged(stableArea: Rect)Indicates that the stable area provided by the host has changed. |
Unit |
onSurfaceAvailable(surfaceContainer: SurfaceContainer)Provides a |
Unit |
onSurfaceDestroyed(surfaceContainer: SurfaceContainer)Indicates that the |
Unit |
onVisibleAreaChanged(visibleArea: Rect)Indicates that the visible area provided by the host has changed. |
Public functions
onClick
@RequiresCarApi(value = 5)
fun onClick(x: Float, y: Float): Unit
Provides information about a click event on the car screen.
See androidx.car.app.navigation.model.NavigationTemplate class description for more details on how to receive this callback.
This method may not be called in some car systems.
onFling
@RequiresCarApi(value = 2)
fun onFling(velocityX: Float, velocityY: Float): Unit
Provides information about a fling touch event on the car screen.
See androidx.car.app.navigation.model.NavigationTemplate class description for more details on how to receive this callback.
This method may not be called in some car systems.
onScale
@RequiresCarApi(value = 2)
fun onScale(focusX: Float, focusY: Float, scaleFactor: Float): Unit
Provides information about a scale touch event on the car screen.
See androidx.car.app.navigation.model.NavigationTemplate class description for more details on how to receive this callback.
This method may not be called in some car systems.
| Parameters | |
|---|---|
focusX: Float |
x coordinate of the focal point in pixels. A negative value indicates that the focal point is unavailable. |
focusY: Float |
y coordinate of the focal point in pixels. A negative value indicates that the focal point is unavailable. |
scaleFactor: Float |
the scaling factor from the previous state to the current state during the scale event. This value is defined as (current state) / (previous state) |
onScroll
@RequiresCarApi(value = 2)
fun onScroll(distanceX: Float, distanceY: Float): Unit
Provides information about a scroll touch event on the car screen.
See androidx.car.app.navigation.model.NavigationTemplate class description for more details on how to receive this callback.
onStableAreaChanged
fun onStableAreaChanged(stableArea: Rect): Unit
Indicates that the stable area provided by the host has changed.
The surface may be occluded for several reasons including status bar changes, overlays from other apps or dynamic UI within the template (also see onVisibleAreaChanged). The stable area is the visual area that accounts for these occlusions as if they were always present. If the app needs to show more persistent data that do not necessarily adjust based on these dynamic content changes, it should be bounded by this area.
onSurfaceAvailable
fun onSurfaceAvailable(surfaceContainer: SurfaceContainer): Unit
Provides a SurfaceContainer from the host which is ready for drawing.
This method may be called multiple times if the surface changes characteristics. For instance, the size or DPI may change without the underlying surface being destroyed.
This method is guaranteed to be called before any other methods on this listener.
Important: every instance of android.view.Surface received through this method must be released by calling release.
| Parameters | |
|---|---|
surfaceContainer: SurfaceContainer |
the |
onSurfaceDestroyed
fun onSurfaceDestroyed(surfaceContainer: SurfaceContainer): Unit
Indicates that the SurfaceContainer provided by the host will be destroyed after this callback.
| Parameters | |
|---|---|
surfaceContainer: SurfaceContainer |
the |
onVisibleAreaChanged
fun onVisibleAreaChanged(visibleArea: Rect): Unit
Indicates that the visible area provided by the host has changed.
The surface may be occluded for several reasons including status bar changes, overlays from other apps or dynamic UI within a template. visibleArea is the area currently guaranteed to not be occluded by any other UI. If the app needs to show critical data, it should be bounded by this area.