public final class

SurfaceContainer

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.SurfaceContainer

Gradle dependencies

compile group: 'androidx.car.app', name: 'app', version: '1.7.0-beta01'

  • groupId: androidx.car.app
  • artifactId: app
  • version: 1.7.0-beta01

Artifact androidx.car.app:app:1.7.0-beta01 it located at Google repository (https://maven.google.com/)

Overview

A container for the created by the host and its associated properties.

Summary

Constructors
publicSurfaceContainer(Surface surface, int width, int height, int dpi)

Methods
public intgetDpi()

Returns the pixel density of the surface or 0 if the surface is not ready.

public intgetHeight()

Returns the height of the surface or 0 if the surface is not ready.

public SurfacegetSurface()

Returns the held by the host or null if the surface is not ready.

public intgetWidth()

Returns the width of the surface or 0 if the surface is not ready.

public java.lang.StringtoString()

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructors

public SurfaceContainer(Surface surface, int width, int height, int dpi)

Methods

public Surface getSurface()

Returns the held by the host or null if the surface is not ready.

public int getWidth()

Returns the width of the surface or 0 if the surface is not ready.

public int getHeight()

Returns the height of the surface or 0 if the surface is not ready.

public int getDpi()

Returns the pixel density of the surface or 0 if the surface is not ready.

public java.lang.String toString()

Source

/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.car.app;

import android.view.Surface;

import androidx.annotation.Nullable;
import androidx.car.app.annotations.CarProtocol;
import androidx.car.app.annotations.KeepFields;

/** A container for the {@link Surface} created by the host and its associated properties. */
@CarProtocol
@KeepFields
public final class SurfaceContainer {
    @Nullable
    private final Surface mSurface;
    private final int mWidth;
    private final int mHeight;
    private final int mDpi;

    public SurfaceContainer(@Nullable Surface surface, int width, int height, int dpi) {
        mSurface = surface;
        mWidth = width;
        mHeight = height;
        mDpi = dpi;
    }

    // No argument constructor needs for serialization.
    private SurfaceContainer() {
        mSurface = null;
        mWidth = 0;
        mHeight = 0;
        mDpi = 0;
    }

    /** Returns the {@link Surface} held by the host or {@code null} if the surface is not ready. */
    @Nullable
    public Surface getSurface() {
        return mSurface;
    }

    /** Returns the width of the surface or 0 if the surface is not ready. */
    public int getWidth() {
        return mWidth;
    }

    /** Returns the height of the surface or 0 if the surface is not ready. */
    public int getHeight() {
        return mHeight;
    }

    /** Returns the pixel density of the surface or 0 if the surface is not ready. */
    public int getDpi() {
        return mDpi;
    }

    @Override
    public String toString() {
        return "[" + mSurface + ", " + mWidth + "x" + mHeight + ", dpi: " + mDpi + "]";
    }
}