From 7e5647d57ffa19c6825566e5375139f3f7b960e3 Mon Sep 17 00:00:00 2001 From: Gerardo Pacheco Date: Wed, 25 Jul 2018 10:02:04 +0200 Subject: [PATCH] Android: MediaPlayer - Prevent screen from dimming, fixed bug and simplified code --- .../com/brentvatne/react/ReactVideoView.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/android/src/main/java/com/brentvatne/react/ReactVideoView.java b/android/src/main/java/com/brentvatne/react/ReactVideoView.java index 217f73f5..a8cd590c 100644 --- a/android/src/main/java/com/brentvatne/react/ReactVideoView.java +++ b/android/src/main/java/com/brentvatne/react/ReactVideoView.java @@ -503,24 +503,12 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP this.mUseNativeControls = controls; } - public boolean isPreventScreenFromDimmingFlagOn() { - int flags = mThemedReactContext.getCurrentActivity().getWindow().getAttributes().flags; - - if ((flags & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) == 0) { - return false; - } - - return true; - } - public void setPreventScreenFromDimmingFlag(final boolean state) { - if (!mMediaPlayerValid && mThemedReactContext == null) { + if (!mMediaPlayerValid || mThemedReactContext == null) { return; } - final boolean isFlagOn = isPreventScreenFromDimmingFlagOn(); - - if (state && !isFlagOn) { + if (state) { mThemedReactContext.getCurrentActivity().runOnUiThread(new Runnable() { @Override public void run() { @@ -529,7 +517,7 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP }); } - if (!state && isFlagOn) { + if (!state) { mThemedReactContext.getCurrentActivity().runOnUiThread(new Runnable() { @Override public void run() {