Fix: java.lang.NumberFormatException when applying clip-path with percentage values

Resolves #3007
This commit is contained in:
Rossen Hristov
2016-11-02 16:59:06 +02:00
parent d045306a2c
commit 28f084e7d2
5 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,11 @@
.container {
width: 200;
height: 200;
clip-path: polygon(50% 3%, 3% 100%, 100% 100%);
background-color: black;
}
.elementStyle {
width: 200;
height: 200;
clip-path: polygon(50% 3%, 3% 100%, 100% 100%);
}

View File

@ -0,0 +1,10 @@
<Page id="Page" xmlns="http://schemas.nativescript.org/tns.xsd">
<StackLayout id="StackLayout">
<Image id="Image" width="100" height="100" class="elementStyle" src="~/ui-tests-app/image-view/gravatar.png"/>
<Button id="Button" backgroundColor="blue" class="elementStyle" text="TAP" />
<Label id="Label" backgroundColor="red" class="elementStyle" text="sample label" textWrap="true"/>
<TextField id="TextField" backgroundColor="green" class="elementStyle" hint="" text="Sample textfield" />
<TextView id="TextView" class="elementStyle" text="Sample text view" backgroundColor="yellow" editable="true" />
<AbsoluteLayout id="AbsoluteLayout" class="container"/>
</StackLayout>
</Page>

View File

@ -14,6 +14,7 @@ export function pageLoaded(args: EventData) {
examples.set("2911", "issues/issue-2911"); examples.set("2911", "issues/issue-2911");
examples.set("2674", "issues/issue-2674"); examples.set("2674", "issues/issue-2674");
examples.set("2942", "issues/issue-2942"); examples.set("2942", "issues/issue-2942");
examples.set("3007", "issues/issue-3007");
let viewModel = new SubMianPageViewModel(wrapLayout, examples); let viewModel = new SubMianPageViewModel(wrapLayout, examples);
page.bindingContext = viewModel; page.bindingContext = viewModel;

View File

@ -67,7 +67,7 @@ export module ad {
_defaultBackgrounds.set(viewClass, nativeView.getBackground()); _defaultBackgrounds.set(viewClass, nativeView.getBackground());
} }
backgroundDrawable = new org.nativescript.widgets.BorderDrawable(density); backgroundDrawable = new org.nativescript.widgets.BorderDrawable(density, v.toString());
refreshBorderDrawable(v, <org.nativescript.widgets.BorderDrawable>backgroundDrawable); refreshBorderDrawable(v, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
nativeView.setBackground(backgroundDrawable); nativeView.setBackground(backgroundDrawable);
} }
@ -116,6 +116,7 @@ export module ad {
} }
function refreshBorderDrawable(view: view.View, borderDrawable: org.nativescript.widgets.BorderDrawable){ function refreshBorderDrawable(view: view.View, borderDrawable: org.nativescript.widgets.BorderDrawable){
//console.log(`>>> refreshBorderDrawable(${view})...`);
let background = <background.Background>view.style._getValue(style.backgroundInternalProperty); let background = <background.Background>view.style._getValue(style.backgroundInternalProperty);
if (background){ if (background){
let backgroundPositionParsedCSSValues: native.Array<org.nativescript.widgets.CSSValue> = null; let backgroundPositionParsedCSSValues: native.Array<org.nativescript.widgets.CSSValue> = null;
@ -154,6 +155,7 @@ function refreshBorderDrawable(view: view.View, borderDrawable: org.nativescript
background.size, background.size,
backgroundSizeParsedCSSValues backgroundSizeParsedCSSValues
); );
//console.log(`>>> ${borderDrawable.toDebugString()}`);
} }
} }

View File

@ -47,6 +47,7 @@
export class BorderDrawable extends android.graphics.drawable.ColorDrawable { export class BorderDrawable extends android.graphics.drawable.ColorDrawable {
constructor(density: number); constructor(density: number);
constructor(density: number, id: string);
public refresh( public refresh(
borderTopColor: number, borderTopColor: number,
borderRightColor: number, borderRightColor: number,
@ -104,6 +105,8 @@
public hasUniformBorderWidth(): boolean; public hasUniformBorderWidth(): boolean;
public hasUniformBorderRadius(): boolean; public hasUniformBorderRadius(): boolean;
public hasUniformBorder(): boolean; public hasUniformBorder(): boolean;
public toDebugString(): string;
} }
export class CSSValue { export class CSSValue {