mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix(css-android): restore elements' native features if offending css is removed while the app is running (#7789)
This commit is contained in:

committed by
Manol Donev

parent
f82cf08f95
commit
2beae5be8e
@ -40,7 +40,7 @@ export module ad {
|
||||
}
|
||||
|
||||
const background = view.style.backgroundInternal;
|
||||
const drawable = nativeView.getBackground();
|
||||
let drawable = nativeView.getBackground();
|
||||
const androidView = <any>view as AndroidView;
|
||||
// use undefined as not set. getBackground will never return undefined only Drawable or null;
|
||||
if (androidView._cachedDrawable === undefined && drawable) {
|
||||
@ -50,12 +50,21 @@ export module ad {
|
||||
|
||||
if (isSetColorFilterOnlyWidget(nativeView)
|
||||
&& drawable
|
||||
&& !(drawable instanceof org.nativescript.widgets.BorderDrawable)
|
||||
&& !background.hasBorderWidth()
|
||||
&& !background.hasBorderRadius()
|
||||
&& !background.clipPath
|
||||
&& !background.image
|
||||
&& background.color) {
|
||||
|
||||
if (drawable instanceof org.nativescript.widgets.BorderDrawable) {
|
||||
if (!(androidView._cachedDrawable instanceof android.graphics.drawable.Drawable.ConstantState)) {
|
||||
return;
|
||||
}
|
||||
|
||||
drawable = androidView._cachedDrawable.newDrawable(nativeView.getResources());
|
||||
nativeView.setBackground(drawable);
|
||||
}
|
||||
|
||||
const backgroundColor = (<any>drawable).backgroundColor = background.color.android;
|
||||
drawable.mutate();
|
||||
drawable.setColorFilter(backgroundColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
|
Reference in New Issue
Block a user