mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
FIX: Background drawable cache conflicts with local property (#4633)
This commit is contained in:
committed by
SvetoslavTsenov
parent
2dbd1b19ea
commit
7983895c8e
@@ -961,6 +961,17 @@ export function testBackgroundImage() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function testBackgroundShorthand_With_EmptyBorder() {
|
||||||
|
// Related to issue https://github.com/NativeScript/NativeScript/issues/4415
|
||||||
|
const lbl = new Label();
|
||||||
|
lbl.className = "test";
|
||||||
|
const css = ".test { border-width: 0; background: transparent; }";
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(lbl, (views: Array<View>) => {
|
||||||
|
helper.waitUntilLayoutReady(lbl);
|
||||||
|
}, css);
|
||||||
|
};
|
||||||
|
|
||||||
export function test_automation_text_default_value() {
|
export function test_automation_text_default_value() {
|
||||||
let view = new Button();
|
let view = new Button();
|
||||||
TKUnit.assertTrue(view.automationText === undefined, "AutomationText default value should be UNDEFINED.");
|
TKUnit.assertTrue(view.automationText === undefined, "AutomationText default value should be UNDEFINED.");
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { android as androidApp } from "../../application";
|
|||||||
export * from "./background-common"
|
export * from "./background-common"
|
||||||
|
|
||||||
interface AndroidView {
|
interface AndroidView {
|
||||||
background: android.graphics.drawable.Drawable.ConstantState;
|
_cachedDrawableConstState: android.graphics.drawable.Drawable.ConstantState;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Change this implementation to use
|
// TODO: Change this implementation to use
|
||||||
@@ -41,8 +41,8 @@ export module ad {
|
|||||||
const drawable = nativeView.getBackground();
|
const drawable = nativeView.getBackground();
|
||||||
const androidView = <any>view as AndroidView;
|
const androidView = <any>view as AndroidView;
|
||||||
// use undefined as not set. getBackground will never return undefined only Drawable or null;
|
// use undefined as not set. getBackground will never return undefined only Drawable or null;
|
||||||
if (androidView.background === undefined && drawable) {
|
if (androidView._cachedDrawableConstState === undefined && drawable) {
|
||||||
androidView.background = drawable.getConstantState();
|
androidView._cachedDrawableConstState = drawable.getConstantState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSetColorFilterOnlyWidget(nativeView)
|
if (isSetColorFilterOnlyWidget(nativeView)
|
||||||
@@ -77,10 +77,10 @@ export module ad {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: newDrawable for BitmapDrawable will fail if we don't speicfy resource. Use the other overload.
|
// TODO: newDrawable for BitmapDrawable will fail if we don't specify resource. Use the other overload.
|
||||||
const defaultDrawable = androidView.background ? androidView.background.newDrawable(nativeView.getResources()) : null;
|
const defaultDrawable = androidView._cachedDrawableConstState ? androidView._cachedDrawableConstState.newDrawable(nativeView.getResources()) : null;
|
||||||
org.nativescript.widgets.ViewHelper.setBackground(nativeView, defaultDrawable);
|
org.nativescript.widgets.ViewHelper.setBackground(nativeView, defaultDrawable);
|
||||||
androidView.background = undefined;
|
androidView._cachedDrawableConstState = undefined;
|
||||||
|
|
||||||
if (cache.layerType !== undefined) {
|
if (cache.layerType !== undefined) {
|
||||||
cache.setLayerType(cache.layerType, null);
|
cache.setLayerType(cache.layerType, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user