mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix possible NPE in StatusBarModule
Summary: This diff fixes a NPE happening in StatusBarModule when the style passed by parameter is null. Even if JS shoulnd't send a null value, this method should not crash with an NPE. I'm not changing behavior, only avoiding NPE when status is null Reviewed By: RSNara Differential Revision: D13287057 fbshipit-source-id: cc5ac4e97083d63f2bf65c03bac0dc9bce976423
This commit is contained in:
committed by
Facebook Github Bot
parent
3749da1312
commit
0f3be77b7d
+2
-2
@@ -166,7 +166,7 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setStyle(final String style) {
|
||||
public void setStyle(@Nullable final String style) {
|
||||
final Activity activity = getCurrentActivity();
|
||||
if (activity == null) {
|
||||
FLog.w(ReactConstants.TAG, "StatusBarModule: Ignored status bar change, current activity is null.");
|
||||
@@ -181,7 +181,7 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
|
||||
public void run() {
|
||||
View decorView = activity.getWindow().getDecorView();
|
||||
decorView.setSystemUiVisibility(
|
||||
style.equals("dark-content") ? View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR : 0);
|
||||
"dark-content".equals(style) ? View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR : 0);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user