Skip to content

Commit

Permalink
fix(android): race condition on offBackgroundColor view change detect…
Browse files Browse the repository at this point in the history
…ion (#9922)
  • Loading branch information
NathanWalker committed Jun 4, 2022
1 parent d9a45a5 commit 24c319e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/core/ui/switch/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down

0 comments on commit 24c319e

Please sign in to comment.