File tree Expand file tree Collapse file tree
apps/automated/src/ui/segmented-bar
packages/core/ui/segmented-bar Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as segmentedBarModule from '@nativescript/core/ui/segmented-bar' ;
22import { Color } from '@nativescript/core' ;
3+ import { AndroidHelper } from '@nativescript/core/ui/core/view' ;
34
45export function getNativeTabWidget ( bar : segmentedBarModule . SegmentedBar ) : android . widget . TabWidget {
56 return ( < android . widget . TabHost > bar . android ) . getTabWidget ( ) ;
@@ -44,7 +45,7 @@ export var checkBackgroundColorUpdatedAfterItemSelected = function (bar: segment
4445 const item = bar . items [ i ] ;
4546 const textView = item ?. nativeViewProtected ;
4647
47- const newDrawable = tryCloneDrawable ( view . getBackground ( ) , view . getResources ( ) ) ;
48+ const newDrawable = AndroidHelper . getCopyOrDrawable ( view . getBackground ( ) , view . getResources ( ) ) ;
4849 newDrawable . setColorFilter ( new android . graphics . Paint ( bar . selectedBackgroundColor . android ) . getColorFilter ( ) ) ;
4950
5051 if ( bar . selectedIndex == i ) {
@@ -68,16 +69,5 @@ export var checkBackgroundColorUpdatedAfterItemSelected = function (bar: segment
6869 }
6970 }
7071
71- function tryCloneDrawable ( value : android . graphics . drawable . Drawable , resources : android . content . res . Resources ) : android . graphics . drawable . Drawable {
72- if ( value ) {
73- const constantState = value . getConstantState ( ) ;
74- if ( constantState ) {
75- return constantState . newDrawable ( resources ) ;
76- }
77- }
78-
79- return value ;
80- }
81-
8272 return isValid === 0 ;
8373} ;
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
171171 const backgroundDrawable = viewGroup . getBackground ( ) ;
172172 if ( SDK_VERSION > 21 && backgroundDrawable ) {
173173 const newDrawable = AndroidHelper . getCopyOrDrawable ( backgroundDrawable , nativeView . getResources ( ) ) ;
174- newDrawable . setColorFilter ( new android . graphics . Paint ( color ) . getColorFilter ( ) ) ;
174+ AndroidHelper . setDrawableColor ( color , newDrawable ) ;
175175 viewGroup . setBackground ( newDrawable ) ;
176176 } else {
177177 const stateDrawable = new android . graphics . drawable . StateListDrawable ( ) ;
You can’t perform that action at this time.
0 commit comments