From be1ed23d1bf1c0183a3d4987137788b5f20ce473 Mon Sep 17 00:00:00 2001 From: farfromrefuge Date: Sun, 19 Nov 2023 20:58:36 +0100 Subject: [PATCH] fix(android): prevent error because of N bug https://github.com/NativeScript/NativeScript/pull/10441 --- src/core/index.android.ts | 4 +++- src/ripple/ripple.android.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/index.android.ts b/src/core/index.android.ts index df090937..703dcea9 100644 --- a/src/core/index.android.ts +++ b/src/core/index.android.ts @@ -203,7 +203,9 @@ export function getRippleColor(color: string | Color, alpha = 0) { if (temp.a !== 255 && alpha === 0) { return temp.android; } - return temp.setAlpha(alpha || 61.5).android; + // TODO: we cant use setAlpha until it is fixed in Nativescript or android will be undefined + return new Color(alpha || 61.5, temp.r, temp.g, temp.b).android; + // return temp.setAlpha(alpha || 61.5).android; } return null; } diff --git a/src/ripple/ripple.android.ts b/src/ripple/ripple.android.ts index a710a314..8b2d8406 100644 --- a/src/ripple/ripple.android.ts +++ b/src/ripple/ripple.android.ts @@ -231,9 +231,9 @@ export class Ripple extends RippleBase { Length.toDevicePixels(this.style.borderBottomLeftRadius) ); } else { - const nColor = getRippleColor(color, this.rippleColorAlpha) + const nColor = getRippleColor(color, this.rippleColorAlpha); if (isPostLollipopMR1) { - (this.rippleDrawable as android.graphics.drawable.RippleDrawable).setColor(color?getColorStateList(nColor):null); + (this.rippleDrawable as android.graphics.drawable.RippleDrawable).setColor(color ? getColorStateList(nColor) : null); } else { (this.rippleDrawable as any).rippleShape.getPaint().setColor(nColor); }