fix: review safety checks

This commit is contained in:
olivier bouillet 2022-11-03 23:06:12 +01:00
parent a323bd0523
commit 53fe1973e5

View File

@ -454,7 +454,7 @@ class ReactExoplayerView extends FrameLayout implements
* Adding Player control to the frame layout * Adding Player control to the frame layout
*/ */
private void addPlayerControl() { private void addPlayerControl() {
if(player == null) return; if(playerControlView == null) return;
LayoutParams layoutParams = new LayoutParams( LayoutParams layoutParams = new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT); LayoutParams.MATCH_PARENT);
@ -1802,7 +1802,7 @@ class ReactExoplayerView extends FrameLayout implements
| SYSTEM_UI_FLAG_FULLSCREEN; | SYSTEM_UI_FLAG_FULLSCREEN;
} }
eventEmitter.fullscreenWillPresent(); eventEmitter.fullscreenWillPresent();
if (controls) { if (controls && fullScreenPlayerView != null) {
fullScreenPlayerView.show(); fullScreenPlayerView.show();
} }
post(() -> { post(() -> {
@ -1812,7 +1812,7 @@ class ReactExoplayerView extends FrameLayout implements
} else { } else {
uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
eventEmitter.fullscreenWillDismiss(); eventEmitter.fullscreenWillDismiss();
if (controls) { if (controls && fullScreenPlayerView != null) {
fullScreenPlayerView.dismiss(); fullScreenPlayerView.dismiss();
reLayout(exoPlayerView); reLayout(exoPlayerView);
} }
@ -1889,7 +1889,6 @@ class ReactExoplayerView extends FrameLayout implements
*/ */
public void setControls(boolean controls) { public void setControls(boolean controls) {
this.controls = controls; this.controls = controls;
if (player == null || exoPlayerView == null) return;
if (controls) { if (controls) {
addPlayerControl(); addPlayerControl();
} else { } else {