public class

ExtensionDisplayFeature

extends java.lang.Object

 java.lang.Object

↳androidx.window.extensions.ExtensionDisplayFeature

Gradle dependencies

compile group: 'androidx.window', name: 'window-extensions', version: '1.0.0-alpha01'

  • groupId: androidx.window
  • artifactId: window-extensions
  • version: 1.0.0-alpha01

Artifact androidx.window:window-extensions:1.0.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

Description of a physical feature on the display.

Summary

Fields
public static final intTYPE_FOLD

A fold in the flexible screen without a physical gap.

public static final intTYPE_HINGE

A physical separation with a hinge that allows two display panels to fold.

Constructors
publicExtensionDisplayFeature(Rect bounds, int type)

Methods
public booleanequals(java.lang.Object obj)

public RectgetBounds()

Get the bounding rect of the display feature in window coordinate space.

public intgetType()

Get the type of the display feature.

public inthashCode()

from java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int TYPE_FOLD

A fold in the flexible screen without a physical gap.

public static final int TYPE_HINGE

A physical separation with a hinge that allows two display panels to fold.

Constructors

public ExtensionDisplayFeature(Rect bounds, int type)

Methods

public Rect getBounds()

Get the bounding rect of the display feature in window coordinate space.

public int getType()

Get the type of the display feature.

public boolean equals(java.lang.Object obj)

public int hashCode()

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.window.extensions;

import android.graphics.Rect;

import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Description of a physical feature on the display.
 */
public class ExtensionDisplayFeature {
    /**
     * The bounding rectangle of the feature within the application window in the window
     * coordinate space.
     */
    @NonNull
    private final Rect mBounds;

    /**
     * The physical type of the feature.
     */
    @Type
    private final int mType;

    /**
     * A fold in the flexible screen without a physical gap.
     */
    public static final int TYPE_FOLD = 1;

    /**
     * A physical separation with a hinge that allows two display panels to fold.
     */
    public static final int TYPE_HINGE = 2;

    @Retention(RetentionPolicy.SOURCE)
    @IntDef({
            TYPE_FOLD,
            TYPE_HINGE,
    })
    @interface Type{}

    public ExtensionDisplayFeature(@NonNull Rect bounds, @Type int type) {
        mBounds = new Rect(bounds);
        mType = type;
    }

    /** Get the bounding rect of the display feature in window coordinate space. */
    @NonNull
    public Rect getBounds() {
        return mBounds;
    }

    /** Get the type of the display feature. */
    @Type
    public int getType() {
        return mType;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof ExtensionDisplayFeature)) {
            return false;
        }
        final ExtensionDisplayFeature
                other = (ExtensionDisplayFeature) obj;
        if (mType != other.mType) {
            return false;
        }
        return mBounds.equals(other.mBounds);
    }

    @Override
    public int hashCode() {
        int result = mType;
        result = 31 * result + mBounds.centerX() + mBounds.centerY();
        return result;
    }
}