Fixes NPE in setFontWeight method

Summary:
We have a crash in prod t11090540, urgent fix same way as in setFontStyle
Closes https://github.com/facebook/react-native/pull/7362

Reviewed By: foghina

Differential Revision: D3254158

Pulled By: dmmiller

fb-gh-sync-id: a497d0d4d0e4df9284e328ebb14fee74ba2f899b
fbshipit-source-id: a497d0d4d0e4df9284e328ebb14fee74ba2f899b
This commit is contained in:
Konstantin Raev 2016-05-03 14:37:51 -07:00 committed by Facebook Github Bot 2
parent bb39a2e9da
commit 1fb8643cb6

View File

@ -199,8 +199,12 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
(fontWeightNumeric != -1 && fontWeightNumeric < 500)) {
fontWeight = Typeface.NORMAL;
}
if (fontWeight != view.getTypeface().getStyle()) {
view.setTypeface(view.getTypeface(), fontWeight);
Typeface currentTypeface = view.getTypeface();
if (currentTypeface == null) {
currentTypeface = Typeface.DEFAULT;
}
if (fontWeight != currentTypeface.getStyle()) {
view.setTypeface(currentTypeface, fontWeight);
}
}