mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 22:01:42 +08:00
fix(android): dont create a borderDrawable if not necessary.
That action is slow and should be prevented as much as possible
This commit is contained in:
@ -44,8 +44,11 @@ export namespace ad {
|
|||||||
const constantState = drawable.getConstantState();
|
const constantState = drawable.getConstantState();
|
||||||
androidView._cachedDrawable = constantState || drawable;
|
androidView._cachedDrawable = constantState || drawable;
|
||||||
}
|
}
|
||||||
|
const onlyColor = !background.hasBorderWidth() && !background.hasBorderRadius() && !background.clipPath && !background.image && background.color;
|
||||||
if (isSetColorFilterOnlyWidget(nativeView) && drawable && !background.hasBorderWidth() && !background.hasBorderRadius() && !background.clipPath && !background.image && background.color) {
|
if (drawable instanceof android.graphics.drawable.ColorDrawable && onlyColor) {
|
||||||
|
drawable.setColor(background.color.android);
|
||||||
|
drawable.invalidateSelf();
|
||||||
|
} else if (isSetColorFilterOnlyWidget(nativeView) && drawable && onlyColor) {
|
||||||
if (drawable instanceof org.nativescript.widgets.BorderDrawable && androidView._cachedDrawable) {
|
if (drawable instanceof org.nativescript.widgets.BorderDrawable && androidView._cachedDrawable) {
|
||||||
if (!(androidView._cachedDrawable instanceof android.graphics.drawable.Drawable.ConstantState)) {
|
if (!(androidView._cachedDrawable instanceof android.graphics.drawable.Drawable.ConstantState)) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user