File tree 2 files changed +3
-13
lines changed
apps/automated/src/ui/segmented-bar
packages/core/ui/segmented-bar
2 files changed +3
-13
lines changed Original file line number Diff line number Diff line change 1
1
import * as segmentedBarModule from '@nativescript/core/ui/segmented-bar' ;
2
2
import { Color } from '@nativescript/core' ;
3
+ import { AndroidHelper } from '@nativescript/core/ui/core/view' ;
3
4
4
5
export function getNativeTabWidget ( bar : segmentedBarModule . SegmentedBar ) : android . widget . TabWidget {
5
6
return ( < android . widget . TabHost > bar . android ) . getTabWidget ( ) ;
@@ -44,7 +45,7 @@ export var checkBackgroundColorUpdatedAfterItemSelected = function (bar: segment
44
45
const item = bar . items [ i ] ;
45
46
const textView = item ?. nativeViewProtected ;
46
47
47
- const newDrawable = tryCloneDrawable ( view . getBackground ( ) , view . getResources ( ) ) ;
48
+ const newDrawable = AndroidHelper . getCopyOrDrawable ( view . getBackground ( ) , view . getResources ( ) ) ;
48
49
newDrawable . setColorFilter ( new android . graphics . Paint ( bar . selectedBackgroundColor . android ) . getColorFilter ( ) ) ;
49
50
50
51
if ( bar . selectedIndex == i ) {
@@ -68,16 +69,5 @@ export var checkBackgroundColorUpdatedAfterItemSelected = function (bar: segment
68
69
}
69
70
}
70
71
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
-
82
72
return isValid === 0 ;
83
73
} ;
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ export class SegmentedBarItem extends SegmentedBarItemBase {
171
171
const backgroundDrawable = viewGroup . getBackground ( ) ;
172
172
if ( SDK_VERSION > 21 && backgroundDrawable ) {
173
173
const newDrawable = AndroidHelper . getCopyOrDrawable ( backgroundDrawable , nativeView . getResources ( ) ) ;
174
- newDrawable . setColorFilter ( new android . graphics . Paint ( color ) . getColorFilter ( ) ) ;
174
+ AndroidHelper . setDrawableColor ( color , newDrawable ) ;
175
175
viewGroup . setBackground ( newDrawable ) ;
176
176
} else {
177
177
const stateDrawable = new android . graphics . drawable . StateListDrawable ( ) ;
You can’t perform that action at this time.
0 commit comments