Example usage for android.support.v4.hardware.display DisplayManagerCompat getInstance

List of usage examples for android.support.v4.hardware.display DisplayManagerCompat getInstance

Introduction

In this page you can find the example usage for android.support.v4.hardware.display DisplayManagerCompat getInstance.

Prototype

public static DisplayManagerCompat getInstance(Context context) 

Source Link

Usage

From source file:com.brotherpowers.cameraview.ViewCompat2.java

/**
 * Gets the logical display to which the view's window has been attached.
 *
 * @param view The view./*from  w  w w  .j a v a  2s  .  co m*/
 * @return The logical display, or null if the view is not currently attached to a window.
 */
public static Display getDisplay(@NonNull View view) {
    if (Build.VERSION.SDK_INT >= 17) {
        return view.getDisplay();
    }
    return ViewCompat.isAttachedToWindow(view)
            ? DisplayManagerCompat.getInstance(view.getContext()).getDisplay(Display.DEFAULT_DISPLAY)
            : null;
}

From source file:org.acra.collector.DisplayManagerCollector.java

@NonNull
@Override//ww w  . j a v a  2 s. c  o  m
String collect(ReportField reportField, ReportBuilder reportBuilder) {
    final StringBuilder result = new StringBuilder();
    for (Display display : DisplayManagerCompat.getInstance(context).getDisplays()) {
        result.append(collectDisplayData(display));
    }

    return result.toString();
}

From source file:me.wimanacra.collector.DisplayManagerCollector.java

@NonNull
@Override/*from  w  w  w. jav  a  2 s.c  o m*/
Element collect(ReportField reportField, ReportBuilder reportBuilder) {
    final ComplexElement result = new ComplexElement();
    for (Display display : DisplayManagerCompat.getInstance(context).getDisplays()) {
        try {
            result.put(String.valueOf(display.getDisplayId()), collectDisplayData(display));
        } catch (JSONException e) {
            ACRA.log.w(ACRA.LOG_TAG, "Failed to collect data for display " + display.getDisplayId(), e);
        }
    }

    return result;
}

From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java

/**
 * Checks whether the main display is in landscape.
 *
 * @param context The context to check with.
 * @return <code>true</code> if the main display is in landscape, else <code>false</code>.
 *//*  ww w  .  j  a v  a  2s .  c o  m*/
public static boolean isMainDisplayInLandscape(Context context) {
    int rotation = DisplayManagerCompat.getInstance(context).getDisplay(0).getRotation();
    return rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270;
}