Class DeviceOrientationDelegate
java.lang.Object
com.jwplayer.pub.api.fullscreen.delegates.DeviceOrientationDelegate
- All Implemented Interfaces:
androidx.lifecycle.LifecycleEventObserver,androidx.lifecycle.LifecycleObserver
public class DeviceOrientationDelegate
extends Object
implements androidx.lifecycle.LifecycleEventObserver
Responsible for changing the device orientation during fullscreen and listening to changes in device orientation to enter or exit fullscreen.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanUsed to store whether fullscreen can be exited by rotation. -
Constructor Summary
ConstructorsConstructorDescriptionDeviceOrientationDelegate(android.app.Activity activity, androidx.lifecycle.Lifecycle lifecycle, android.os.Handler handler) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoRotation(boolean fullscreen, boolean allowFullscreenPortrait) Force the screen orientation to change.protected voidStarts a orientation event listener.booleanWhether the current or a very recent device orientation change was performed by the user, as opposed to requested by this delegate.voidonAllowFullscreenPortrait(boolean allowFullscreenPortrait) voidonAllowRotationChanged(boolean allowRotation) voidonStateChanged(androidx.lifecycle.LifecycleOwner source, androidx.lifecycle.Lifecycle.Event event) voidrelease()Detaches this delegate from the process: unregisters the configuration-change callback, stops the orientation sensor listener, and drops any pending orientation restore.voidsetFullscreen(boolean fullscreen) protected longThe clock used for rotation-attribution bookkeeping.
-
Field Details
-
mAllowRotation
protected boolean mAllowRotationUsed to store whether fullscreen can be exited by rotation.
-
-
Constructor Details
-
DeviceOrientationDelegate
public DeviceOrientationDelegate(android.app.Activity activity, androidx.lifecycle.Lifecycle lifecycle, android.os.Handler handler)
-
-
Method Details
-
setFullscreen
public void setFullscreen(boolean fullscreen) -
isUserRotationInProgress
public boolean isUserRotationInProgress()Whether the current or a very recent device orientation change was performed by the user, as opposed to requested by this delegate. Queried while a fullscreen exit is being processed: a host reacting to rotation callsJWPlayer.setFullscreen(false, ...)fromActivity.onConfigurationChanged, within the same main-thread dispatch as the configuration change itself.- Returns:
- true when an orientation change not requested by this delegate is being dispatched
or completed within the last
USER_ROTATION_ATTRIBUTION_WINDOW_MS.
-
release
public void release()Detaches this delegate from the process: unregisters the configuration-change callback, stops the orientation sensor listener, and drops any pending orientation restore. Safe to call more than once. Runs on the host lifecycle's ON_DESTROY, and is also invoked by the SDK when the player owning this delegate is destroyed independently of its Activity (for example a player recycled out of a feed) — the configuration-change callback lives on the application context and would otherwise outlive, and leak, the player and its Activity. -
uptimeMillis
protected long uptimeMillis()The clock used for rotation-attribution bookkeeping. Overridable so tests can control time;SystemClockis not usable in local unit tests. -
onStateChanged
public void onStateChanged(@NonNull androidx.lifecycle.LifecycleOwner source, @NonNull androidx.lifecycle.Lifecycle.Event event) - Specified by:
onStateChangedin interfaceandroidx.lifecycle.LifecycleEventObserver
-
onAllowRotationChanged
public void onAllowRotationChanged(boolean allowRotation) -
doRotation
protected void doRotation(boolean fullscreen, boolean allowFullscreenPortrait) Force the screen orientation to change.Default behavior is to force LANDSCAPE/REVERSE_LANDSCAPE when fullscreen == true and PORTRAIT when fullscreen == false.
- Parameters:
fullscreen- True when entering fullscreen.
-
doRotationListener
protected void doRotationListener()Starts a orientation event listener. -
onAllowFullscreenPortrait
public void onAllowFullscreenPortrait(boolean allowFullscreenPortrait)
-