Skip to content

Commit

Permalink
fix possible NPE in StatusBarModule
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Dec 1, 2018
1 parent 3749da1 commit 0f3be77
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void run() {
}

@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.");
Expand All @@ -181,7 +181,7 @@ public void setStyle(final String style) {
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);
}
}
);
Expand Down

0 comments on commit 0f3be77

Please sign in to comment.