From e16bc606ef6ed506cbc38e50247a59637d898b50 Mon Sep 17 00:00:00 2001 From: Dimitris - Rafail Katsampas Date: Mon, 28 Dec 2020 14:48:14 +0200 Subject: [PATCH] fix: android ActivityIndicator custom color affecting other indicators on the page (#9026) * fix(core): Setting color of an Android ActivityIndicator changed the color of the rest of ActivityIndicators in the same page. * test: Updated ActivityIndicator sample. * perf: Call mutate() only if color is actually changed. --- apps/ui/src/progress-bar/activity-indicator-page.xml | 7 ++++++- packages/core/ui/activity-indicator/index.android.ts | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/ui/src/progress-bar/activity-indicator-page.xml b/apps/ui/src/progress-bar/activity-indicator-page.xml index 1a5c6734e..6040774b1 100644 --- a/apps/ui/src/progress-bar/activity-indicator-page.xml +++ b/apps/ui/src/progress-bar/activity-indicator-page.xml @@ -1,4 +1,9 @@ - + + + + + + diff --git a/packages/core/ui/activity-indicator/index.android.ts b/packages/core/ui/activity-indicator/index.android.ts index 16259e955..bf0c42e89 100644 --- a/packages/core/ui/activity-indicator/index.android.ts +++ b/packages/core/ui/activity-indicator/index.android.ts @@ -47,10 +47,12 @@ export class ActivityIndicator extends ActivityIndicatorBase { return -1; } [colorProperty.setNative](value: number | Color) { - if (value instanceof Color) { - this.nativeViewProtected.getIndeterminateDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN); + const color = value instanceof Color ? value.android : value; + const drawable = this.nativeViewProtected.getIndeterminateDrawable().mutate(); + if (color) { + drawable.setColorFilter(color, android.graphics.PorterDuff.Mode.SRC_IN); } else { - this.nativeViewProtected.getIndeterminateDrawable().clearColorFilter(); + drawable.clearColorFilter(); } } }