@@ -6,7 +6,7 @@ import { android as androidApp } from "../../application";
66export * from "./background-common"
77
88interface AndroidView {
9- background : android . graphics . drawable . Drawable . ConstantState ;
9+ _cachedDrawableConstState : android . graphics . drawable . Drawable . ConstantState ;
1010}
1111
1212// TODO: Change this implementation to use
@@ -41,8 +41,8 @@ export module ad {
4141 const drawable = nativeView . getBackground ( ) ;
4242 const androidView = < any > view as AndroidView ;
4343 // use undefined as not set. getBackground will never return undefined only Drawable or null;
44- if ( androidView . background === undefined && drawable ) {
45- androidView . background = drawable . getConstantState ( ) ;
44+ if ( androidView . _cachedDrawableConstState === undefined && drawable ) {
45+ androidView . _cachedDrawableConstState = drawable . getConstantState ( ) ;
4646 }
4747
4848 if ( isSetColorFilterOnlyWidget ( nativeView )
@@ -77,11 +77,11 @@ export module ad {
7777 }
7878 }
7979 } else {
80- // TODO: newDrawable for BitmapDrawable will fail if we don't speicfy resource. Use the other overload.
81- const defaultDrawable = androidView . background ? androidView . background . newDrawable ( nativeView . getResources ( ) ) : null ;
80+ // TODO: newDrawable for BitmapDrawable will fail if we don't specify resource. Use the other overload.
81+ const defaultDrawable = androidView . _cachedDrawableConstState ? androidView . _cachedDrawableConstState . newDrawable ( nativeView . getResources ( ) ) : null ;
8282 org . nativescript . widgets . ViewHelper . setBackground ( nativeView , defaultDrawable ) ;
83- androidView . background = undefined ;
84-
83+ androidView . _cachedDrawableConstState = undefined ;
84+
8585 if ( cache . layerType !== undefined ) {
8686 cache . setLayerType ( cache . layerType , null ) ;
8787 cache . layerType = undefined ;
0 commit comments