Skip to content

Instantly share code, notes, and snippets.

@atticoos
Created September 21, 2017 20:38
Show Gist options
  • Save atticoos/53fc8919f6b1717b03a719c8dca0c582 to your computer and use it in GitHub Desktop.
Save atticoos/53fc8919f6b1717b03a719c8dca0c582 to your computer and use it in GitHub Desktop.
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