public final class

DisplayRotationHelper

extends Object
implements DisplayManager.DisplayListener
java.lang.Object
   ↳ com.vidinoti.android.vdarsdk.arcore.helpers.DisplayRotationHelper

Class Overview

Helper to track the display rotations. In particular, the 180 degree rotations are not notified by the onSurfaceChanged() callback, and thus they require listening to the android display events. See https://github.com/google-ar/arcore-android-sdk/blob/master/samples/hello_ar_java/app/src/main/java/com/google/ar/core/examples/java/common/helpers/DisplayRotationHelper.java

Summary

Public Constructors
DisplayRotationHelper(Context context)
Constructs the DisplayRotationHelper but does not register the listener yet.
Public Methods
float getCameraSensorRelativeViewportAspectRatio(String cameraId)
Returns the aspect ratio of the GL surface viewport while accounting for the display rotation relative to the device camera sensor orientation.
int getCameraSensorToDisplayRotation(String cameraId)
Returns the rotation of the back-facing camera with respect to the display.
void onDisplayAdded(int displayId)
void onDisplayChanged(int displayId)
void onDisplayRemoved(int displayId)
void onPause()
Unregisters the display listener.
void onResume()
Registers the display listener.
void onSurfaceChanged(int width, int height)
Records a change in surface dimensions.
void updateSessionIfNeeded(Session session)
Updates the session display geometry if a change was posted either by onSurfaceChanged(int, int) call or by onDisplayChanged(int) system callback.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.hardware.display.DisplayManager.DisplayListener

Public Constructors

public DisplayRotationHelper (Context context)

Constructs the DisplayRotationHelper but does not register the listener yet.

Parameters
context the Android Context.

Public Methods

public float getCameraSensorRelativeViewportAspectRatio (String cameraId)

Returns the aspect ratio of the GL surface viewport while accounting for the display rotation relative to the device camera sensor orientation.

public int getCameraSensorToDisplayRotation (String cameraId)

Returns the rotation of the back-facing camera with respect to the display. The value is one of 0, 90, 180, 270.

public void onDisplayAdded (int displayId)

public void onDisplayChanged (int displayId)

public void onDisplayRemoved (int displayId)

public void onPause ()

Unregisters the display listener. Should be called from onPause().

public void onResume ()

Registers the display listener. Should be called from onResume().

public void onSurfaceChanged (int width, int height)

Records a change in surface dimensions. This will be later used by updateSessionIfNeeded(Session). Should be called from android.opengl.GLSurfaceView.Renderer #onSurfaceChanged(javax.microedition.khronos.opengles.GL10, int, int).

Parameters
width the updated width of the surface.
height the updated height of the surface.

public void updateSessionIfNeeded (Session session)

Updates the session display geometry if a change was posted either by onSurfaceChanged(int, int) call or by onDisplayChanged(int) system callback. This function should be called explicitly before each call to Session#update(). This function will also clear the 'pending update' (viewportChanged) flag.

Parameters
session the Session object to update if display geometry changed.