mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(android): race condition on offBackgroundColor view change detection (#9922)
This commit is contained in:
@@ -57,11 +57,13 @@ export class Switch extends SwitchBase {
|
||||
}
|
||||
|
||||
private setNativeBackgroundColor(value: string | number | Color) {
|
||||
if (value instanceof Color) {
|
||||
// todo: use https://developer.android.com/reference/androidx/core/graphics/BlendModeColorFilterCompat
|
||||
this.nativeViewProtected.getTrackDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_OVER);
|
||||
} else {
|
||||
this.nativeViewProtected.getTrackDrawable().clearColorFilter();
|
||||
if (this.nativeViewProtected) {
|
||||
if (value instanceof Color) {
|
||||
// todo: use https://developer.android.com/reference/androidx/core/graphics/BlendModeColorFilterCompat
|
||||
this.nativeViewProtected.getTrackDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_OVER);
|
||||
} else {
|
||||
this.nativeViewProtected.getTrackDrawable().clearColorFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user