@@ -44,21 +44,23 @@ export module ad {
4444
4545 ensureLazyRequires ( ) ;
4646
47- let clipPath = v . style . _getValue ( style . clipPathProperty ) ;
48- let background = < background . Background > v . style . _getValue ( style . backgroundInternalProperty ) ;
49- let borderWidth = v . borderWidth ;
47+ let background = < common . Background > v . style . _getValue ( style . backgroundInternalProperty ) ;
5048 let backgroundDrawable = nativeView . getBackground ( ) ;
5149 let density = utils . layout . getDisplayDensity ( ) ;
5250 let cache = < CacheLayerType > v . _nativeView ;
53- if ( v instanceof button . Button && ! types . isNullOrUndefined ( backgroundDrawable ) && types . isFunction ( backgroundDrawable . setColorFilter ) &&
54- v . borderWidth === 0 && v . borderRadius === 0 && ! clipPath &&
55- types . isNullOrUndefined ( v . style . _getValue ( style . backgroundImageProperty ) ) &&
56- ! types . isNullOrUndefined ( v . style . _getValue ( style . backgroundColorProperty ) ) ) {
57- let backgroundColor = ( < any > backgroundDrawable ) . backgroundColor = v . style . _getValue ( style . backgroundColorProperty ) . android ;
51+ if ( v instanceof button . Button
52+ && ! types . isNullOrUndefined ( backgroundDrawable )
53+ && types . isFunction ( backgroundDrawable . setColorFilter )
54+ && background . borderWidth === 0
55+ && background . borderRadius === 0
56+ && ! background . clipPath
57+ && types . isNullOrUndefined ( background . image )
58+ && ! types . isNullOrUndefined ( background . color ) ) {
59+ let backgroundColor = ( < any > backgroundDrawable ) . backgroundColor = background . color . android ;
5860 backgroundDrawable . setColorFilter ( backgroundColor , android . graphics . PorterDuff . Mode . SRC_IN ) ;
5961 ( < any > backgroundDrawable ) . backgroundColor = backgroundColor ;
6062 }
61- else if ( v . borderWidth || v . borderRadius || clipPath || ! background . isEmpty ( ) ) {
63+ else if ( ! background . isEmpty ( ) ) {
6264 if ( ! ( backgroundDrawable instanceof org . nativescript . widgets . BorderDrawable ) ) {
6365 let viewClass = types . getClass ( v ) ;
6466 if ( ! ( v instanceof button . Button ) && ! _defaultBackgrounds . has ( viewClass ) ) {
@@ -73,7 +75,7 @@ export module ad {
7375 refreshBorderDrawable ( v , < org . nativescript . widgets . BorderDrawable > backgroundDrawable ) ;
7476 }
7577
76- if ( ( v . borderWidth || v . borderRadius || clipPath ) && getSDK ( ) < 18 ) {
78+ if ( ( background . borderWidth || background . borderRadius || background . clipPath ) && getSDK ( ) < 18 ) {
7779 // Switch to software because of unsupported canvas methods if hardware acceleration is on:
7880 // http://developer.android.com/guide/topics/graphics/hardware-accel.html
7981 cache . layerType = cache . getLayerType ( ) ;
@@ -100,60 +102,40 @@ export module ad {
100102 }
101103
102104 nativeView . setPadding (
103- Math . round ( ( borderWidth + v . style . paddingLeft ) * density ) ,
104- Math . round ( ( borderWidth + v . style . paddingTop ) * density ) ,
105- Math . round ( ( borderWidth + v . style . paddingRight ) * density ) ,
106- Math . round ( ( borderWidth + v . style . paddingBottom ) * density )
105+ Math . round ( ( background . borderWidth + v . style . paddingLeft ) * density ) ,
106+ Math . round ( ( background . borderWidth + v . style . paddingTop ) * density ) ,
107+ Math . round ( ( background . borderWidth + v . style . paddingRight ) * density ) ,
108+ Math . round ( ( background . borderWidth + v . style . paddingBottom ) * density )
107109 ) ;
108110 }
109111}
110112
111113function refreshBorderDrawable ( view : view . View , borderDrawable : org . nativescript . widgets . BorderDrawable ) {
112114 let background = < background . Background > view . style . _getValue ( style . backgroundInternalProperty ) ;
113- let borderWidth : number = view . borderWidth ;
114- let borderColor : number = 0 ;
115- if ( view . borderColor && view . borderColor . android ) {
116- borderColor = view . borderColor . android ;
117- }
118- let borderRadius : number = view . borderRadius ;
119- let clipPath : string = view . style . _getValue ( style . clipPathProperty ) ;
120- let backgroundColor : number = 0 ;
121- let backgroundImage : android . graphics . Bitmap = null ;
122- let backgroundRepeat : string = null ;
123- let backgroundPosition : string = null ;
124- let backgroundPositionParsedCSSValues : native . Array < org . nativescript . widgets . CSSValue > = null ;
125- let backgroundSize : string = null ;
126- let backgroundSizeParsedCSSValues : native . Array < org . nativescript . widgets . CSSValue > = null ;
127115 if ( background ) {
128- if ( background . color && background . color . android ) {
129- backgroundColor = background . color . android ;
130- }
131- if ( background . image && background . image . android ) {
132- backgroundImage = background . image . android ;
133- }
116+ let backgroundPositionParsedCSSValues : native . Array < org . nativescript . widgets . CSSValue > = null ;
117+ let backgroundSizeParsedCSSValues : native . Array < org . nativescript . widgets . CSSValue > = null ;
134118 if ( background . position ) {
135- backgroundPosition = background . position ;
136119 backgroundPositionParsedCSSValues = createNativeCSSValueArray ( background . position ) ;
137120 }
138121 if ( background . size ) {
139- backgroundSize = background . size ;
140122 backgroundSizeParsedCSSValues = createNativeCSSValueArray ( background . size ) ;
141123 }
124+
125+ borderDrawable . refresh (
126+ background . borderWidth ,
127+ ( background . borderColor && background . borderColor . android ) ? background . borderColor . android : 0 ,
128+ background . borderRadius ,
129+ background . clipPath ,
130+ ( background . color && background . color . android ) ? background . color . android : 0 ,
131+ ( background . image && background . image . android ) ? background . image . android : null ,
132+ background . repeat ,
133+ background . position ,
134+ backgroundPositionParsedCSSValues ,
135+ background . size ,
136+ backgroundSizeParsedCSSValues
137+ ) ;
142138 }
143-
144- borderDrawable . refresh (
145- borderWidth ,
146- borderColor ,
147- borderRadius ,
148- clipPath ,
149- backgroundColor ,
150- backgroundImage ,
151- backgroundRepeat ,
152- backgroundPosition ,
153- backgroundPositionParsedCSSValues ,
154- backgroundSize ,
155- backgroundSizeParsedCSSValues
156- ) ;
157139}
158140
159141function createNativeCSSValueArray ( css : string ) : native . Array < org . nativescript . widgets . CSSValue > {
0 commit comments