Created
September 21, 2017 20:38
-
-
Save atticoos/53fc8919f6b1717b03a719c8dca0c582 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ImmersiveModeModule extends ReactContextBaseJavaModule { | |
public static final String TAG = "ImmersiveMode"; | |
private Handler uiHandler; | |
private Runnable mRunnable; | |
public ImmersiveModeModule(ReactApplicationContext reactContext) { | |
super(reactContext); | |
uiHandler = new Handler(reactContext.getMainLooper()); | |
mRunnable = new Runnable() { | |
@Override | |
public void run() { | |
Activity activity = getCurrentActivity(); | |
if (activity != null) { | |
activity.getWindow().getDecorView().setSystemUiVisibility( | |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | |
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | |
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| View.SYSTEM_UI_FLAG_FULLSCREEN | |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); | |
} | |
} | |
}; | |
} | |
@Override | |
public String getName() { | |
return "ImmersiveMode"; | |
} | |
@ReactMethod | |
public void enter(Promise promise) { | |
uiHandler.post(mRunnable); | |
promise.resolve(null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment