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:
David Vacca
2018-12-17 19:52:39 +01:00
committed by Mike Grabowski
parent d8f28ceef8
commit c43b7b93b2
@@ -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);
}
}
);