ViewfinderSurfaceRequest.Result


@AutoValue
public final class ViewfinderSurfaceRequest.Result


Result of providing a surface to a ViewfinderSurfaceRequest via .provideSurface.

Can be used to compare to results returned to resultListener in .provideSurface.

Summary

Constants

static final int

Provided surface could not be used by the producer.

static final int

Provided surface was never attached to the producer due to the ViewfinderSurfaceRequest being cancelled by the producer.

static final int

Surface was not attached to the producer through this invocation of .provideSurface due to the ViewfinderSurfaceRequest already being complete with a surface.

static final int

Provided surface was successfully used by the producer and eventually detached once no longer needed by the producer.

static final int

Surface was not attached to the producer through this invocation of .provideSurface due to the ViewfinderSurfaceRequest already being marked as "will not provide surface".

Public constructors

Result(int code, @NonNull Surface surface)

Public methods

final int

One of .RESULT_SURFACE_USED_SUCCESSFULLY, .RESULT_REQUEST_CANCELLED, .RESULT_INVALID_SURFACE, .RESULT_SURFACE_ALREADY_PROVIDED, or .RESULT_WILL_NOT_PROVIDE_SURFACE.

final @NonNull Surface

The Surface used to complete the ViewfinderSurfaceRequest.

Constants

RESULT_INVALID_SURFACE

public static final int RESULT_INVALID_SURFACE = 2

Provided surface could not be used by the producer.

This is likely due to the Surface being closed prematurely or the resolution of the surface not matching the resolution specified by ViewfinderSurfaceRequest.resolution.

RESULT_REQUEST_CANCELLED

public static final int RESULT_REQUEST_CANCELLED = 1

Provided surface was never attached to the producer due to the ViewfinderSurfaceRequest being cancelled by the producer.

It is safe to release or reuse Surface, assuming it was not previously attached to a producer via .provideSurface. If reusing the surface for a future surface request, it should be verified that the surface still matches the resolution specified by ViewfinderSurfaceRequest.resolution.

RESULT_SURFACE_ALREADY_PROVIDED

public static final int RESULT_SURFACE_ALREADY_PROVIDED = 3

Surface was not attached to the producer through this invocation of .provideSurface due to the ViewfinderSurfaceRequest already being complete with a surface.

The ViewfinderSurfaceRequest has already been completed by a previous invocation of .provideSurface.

It is safe to release or reuse the Surface, assuming it was not previously attached to a producer via .provideSurface.

RESULT_SURFACE_USED_SUCCESSFULLY

public static final int RESULT_SURFACE_USED_SUCCESSFULLY = 0

Provided surface was successfully used by the producer and eventually detached once no longer needed by the producer.

This result denotes that it is safe to release the Surface and any underlying resources.

For compatibility reasons, the Surface object should not be reused by future SurfaceRequests, and a new surface should be created instead.

RESULT_WILL_NOT_PROVIDE_SURFACE

public static final int RESULT_WILL_NOT_PROVIDE_SURFACE = 4

Surface was not attached to the producer through this invocation of .provideSurface due to the ViewfinderSurfaceRequest already being marked as "will not provide surface".

The ViewfinderSurfaceRequest has already been marked as 'will not provide surface' by a previous invocation of .willNotProvideSurface.

It is safe to release or reuse the Surface, assuming it was not previously attached to a producer via .provideSurface.

Public constructors

Result

Added in 1.4.0-alpha11
public Result(int code, @NonNull Surface surface)
Parameters
int code

One of .RESULT_SURFACE_USED_SUCCESSFULLY, .RESULT_REQUEST_CANCELLED, .RESULT_INVALID_SURFACE, .RESULT_SURFACE_ALREADY_PROVIDED, or .RESULT_WILL_NOT_PROVIDE_SURFACE.

@NonNull Surface surface

The Surface used to complete the ViewfinderSurfaceRequest.

Public methods

getCode

Added in 1.4.0-alpha11
public final int getCode()

One of .RESULT_SURFACE_USED_SUCCESSFULLY, .RESULT_REQUEST_CANCELLED, .RESULT_INVALID_SURFACE, .RESULT_SURFACE_ALREADY_PROVIDED, or .RESULT_WILL_NOT_PROVIDE_SURFACE.

getSurface

Added in 1.4.0-alpha11
public final @NonNull Surface getSurface()

The Surface used to complete the ViewfinderSurfaceRequest.