Files
NativeScript/tns-core-modules/ui/html-view/html-view.android.ts
Hristo Hristov 09535627b9 disable recycling on specific button (#4527)
* disable recycling on specific button
add more thorough test for view recycling
fix memory leak with android ActionBar
improve padding reset when view is recycled
improve reset of several controls

* stopping local animations when view is recycled
fix tns-ios version in tests/package.json

* Fix isClickable on android when reusing nativeView
2017-07-11 09:48:08 +03:00

42 lines
1.3 KiB
TypeScript

import {
HtmlViewBase, htmlProperty
} from "./html-view-common";
export * from "./html-view-common";
export class HtmlView extends HtmlViewBase {
nativeView: android.widget.TextView;
public createNativeView() {
return new android.widget.TextView(this._context);
}
public initNativeView(): void {
super.initNativeView();
const nativeView = this.nativeView;
// This makes the html <a href...> work
nativeView.setLinksClickable(true);
nativeView.setMovementMethod(android.text.method.LinkMovementMethod.getInstance());
}
public resetNativeView(): void {
super.resetNativeView();
this.nativeView.setAutoLinkMask(0);
}
[htmlProperty.getDefault](): string {
return "";
}
[htmlProperty.setNative](value: string) {
// If the data.newValue actually has a <a...> in it; we need to disable autolink mask
// it internally disables the coloring, but then the <a> links won't work.. So to support both
// styles of links (html and just text based) we have to manually enable/disable the autolink mask
let mask = 15;
if (value.search(/<a\s/i) >= 0) {
mask = 0;
}
this.nativeView.setAutoLinkMask(mask);
this.nativeView.setText(<any>android.text.Html.fromHtml(value));
}
}