Google is committed to advancing racial equity for Black communities. See how.

SurfaceListener

public interface SurfaceListener

com.google.android.libraries.car.app.SurfaceListener


A listener for changes on the SurfaceContainer and its attributes.

Summary

Public methods

abstract void onStableAreaChanged(Rect stableArea)

Indicates that the stable area provided by the host has changed.

abstract void onSurfaceAvailable(SurfaceContainer surfaceContainer)

Provides a SurfaceContainer from the host which is ready for drawing.

abstract void onSurfaceDestroyed(SurfaceContainer surfaceContainer)

Indicates that the SurfaceContainer provided by the host will be destroyed after this callback.

abstract void onVisibleAreaChanged(Rect visibleArea)

Indicates that the visible area provided by the host has changed.

Public methods

onStableAreaChanged

public abstract void onStableAreaChanged (Rect stableArea)

Indicates that the stable area provided by the host has changed.

The visible area (see onVisibleAreaChanged(Rect) can be occluded for several reasons including status bar changes, overlays from other apps or dynamic UI within the template. The stable area is the visual area which will not be occluded by known dynamic content. The area may change at any time, but every effort is made to keep it constant.

Parameters
stableArea Rect: Inset rectangle of the surface space designated as stable. If Rect.isEmpty() returns true for the stable area, then it is currently unknown.

onSurfaceAvailable

public abstract void onSurfaceAvailable (SurfaceContainer surfaceContainer)

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.

Parameters
surfaceContainer SurfaceContainer: The SurfaceContainer that is ready for drawing.

onSurfaceDestroyed

public abstract void onSurfaceDestroyed (SurfaceContainer surfaceContainer)

Indicates that the SurfaceContainer provided by the host will be destroyed after this callback.

Parameters
surfaceContainer SurfaceContainer: The SurfaceContainer being destroyed.

onVisibleAreaChanged

public abstract void onVisibleAreaChanged (Rect visibleArea)

Indicates that the visible area provided by the host has changed.

The visible area may be occluded for several reasons including status bar changes, overlays from other apps or dynamic UI within a template. The inset is the area currently guaranteed to not be occluded by any other UI. If the app needs to show critical data, it should be within the inset area.

Parameters
visibleArea Rect: The rectangle set to the surface area guaranteed to be visible. If Rect.isEmpty() returns true for the visible area, then it is currently unknown.