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() {
|
||||
let view = new Button();
|
||||
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"
|
||||
|
||||
interface AndroidView {
|
||||
background: android.graphics.drawable.Drawable.ConstantState;
|
||||
_cachedDrawableConstState: android.graphics.drawable.Drawable.ConstantState;
|
||||
}
|
||||
|
||||
// TODO: Change this implementation to use
|
||||
@@ -41,8 +41,8 @@ export module ad {
|
||||
const 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.background === undefined && drawable) {
|
||||
androidView.background = drawable.getConstantState();
|
||||
if (androidView._cachedDrawableConstState === undefined && drawable) {
|
||||
androidView._cachedDrawableConstState = drawable.getConstantState();
|
||||
}
|
||||
|
||||
if (isSetColorFilterOnlyWidget(nativeView)
|
||||
@@ -77,11 +77,11 @@ export module ad {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO: newDrawable for BitmapDrawable will fail if we don't speicfy resource. Use the other overload.
|
||||
const defaultDrawable = androidView.background ? androidView.background.newDrawable(nativeView.getResources()) : null;
|
||||
// TODO: newDrawable for BitmapDrawable will fail if we don't specify resource. Use the other overload.
|
||||
const defaultDrawable = androidView._cachedDrawableConstState ? androidView._cachedDrawableConstState.newDrawable(nativeView.getResources()) : null;
|
||||
org.nativescript.widgets.ViewHelper.setBackground(nativeView, defaultDrawable);
|
||||
androidView.background = undefined;
|
||||
|
||||
androidView._cachedDrawableConstState = undefined;
|
||||
|
||||
if (cache.layerType !== undefined) {
|
||||
cache.setLayerType(cache.layerType, null);
|
||||
cache.layerType = undefined;
|
||||
|
||||
Reference in New Issue
Block a user