Fix crash where some android Drawables doesn't implement getConstantState... (#4742)

Changed all places where getConstantState was used.
This commit is contained in:
Hristo Hristov
2017-08-24 11:06:33 +03:00
committed by GitHub
parent d6689a04b2
commit b6d5510627
4 changed files with 64 additions and 22 deletions

View File

@@ -459,7 +459,16 @@ export class View extends ViewCommon {
[backgroundInternalProperty.getDefault](): android.graphics.drawable.Drawable {
const nativeView = this.nativeViewProtected;
const drawable = nativeView.getBackground();
return drawable ? drawable.getConstantState().newDrawable(nativeView.getResources()) : null;
if (drawable) {
const constantState = drawable.getConstantState();
if (constantState) {
return constantState.newDrawable(nativeView.getResources());
} else {
return drawable;
}
}
return null;
}
[backgroundInternalProperty.setNative](value: android.graphics.drawable.Drawable | Background) {
this._redrawNativeBackground(value);