_createNativeView to createNativeView;
_initNativeView to initNativeView
_disposeNativeView to disposeNativeView
_resetNativeView to resetNativeView
This commit is contained in:
Hristo Hristov
2017-03-28 13:05:11 +03:00
parent f2898f84d5
commit c18a76c93a
38 changed files with 111 additions and 110 deletions

View File

@ -68,15 +68,15 @@ class NativeGridLayout extends org.nativescript.widgets.GridLayout {
export class MyButton extends Button implements def.MyButton { export class MyButton extends Button implements def.MyButton {
nativeView: NativeButton; nativeView: NativeButton;
public _createNativeView() { public createNativeView() {
return new NativeButton(this._context, this); return new NativeButton(this._context, this);
} }
public _initNativeView(): void { public initNativeView(): void {
this.nativeView.owner = this; this.nativeView.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
this.nativeView.owner = undefined; this.nativeView.owner = undefined;
} }
@ -121,15 +121,15 @@ export class MyButton extends Button implements def.MyButton {
export class MyStackLayout extends StackLayout implements def.MyStackLayout { export class MyStackLayout extends StackLayout implements def.MyStackLayout {
nativeView: NativeStackLayout; nativeView: NativeStackLayout;
public _createNativeView() { public createNativeView() {
return new NativeStackLayout(this._context, this); return new NativeStackLayout(this._context, this);
} }
public _initNativeView(): void { public initNativeView(): void {
this.nativeView.owner = this; this.nativeView.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
this.nativeView.owner = undefined; this.nativeView.owner = undefined;
} }
@ -174,15 +174,15 @@ export class MyStackLayout extends StackLayout implements def.MyStackLayout {
export class MyGridLayout extends GridLayout implements def.MyGridLayout { export class MyGridLayout extends GridLayout implements def.MyGridLayout {
nativeView: NativeGridLayout; nativeView: NativeGridLayout;
public _createNativeView() { public createNativeView() {
return new NativeGridLayout(this._context, this); return new NativeGridLayout(this._context, this);
} }
public _initNativeView(): void { public initNativeView(): void {
this.nativeView.owner = this; this.nativeView.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
this.nativeView.owner = undefined; this.nativeView.owner = undefined;
} }

View File

@ -281,13 +281,13 @@ class TestView extends Layout {
this.nativeView = undefined; this.nativeView = undefined;
} }
public _createNativeView() { public createNativeView() {
if (isIOS) { if (isIOS) {
this.nativeView = this._nativeView; this.nativeView = this._nativeView;
return this._nativeView; return this._nativeView;
} }
return super._createNativeView(); return super.createNativeView();
} }
public toString() { public toString() {

View File

@ -127,7 +127,7 @@ export class ActionBar extends ActionBarBase {
} }
} }
public _createNativeView() { public createNativeView() {
initializeMenuItemClickListener(); initializeMenuItemClickListener();
const toolbar = new android.support.v7.widget.Toolbar(this._context); const toolbar = new android.support.v7.widget.Toolbar(this._context);
const menuItemClickListener = new MenuItemClickListener(this); const menuItemClickListener = new MenuItemClickListener(this);
@ -136,11 +136,11 @@ export class ActionBar extends ActionBarBase {
return toolbar; return toolbar;
} }
public _initNativeView(): void { public initNativeView(): void {
(<any>this.nativeView).menuItemClickListener.owner = this; (<any>this.nativeView).menuItemClickListener.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
(<any>this.nativeView).menuItemClickListener.owner = null; (<any>this.nativeView).menuItemClickListener.owner = null;
} }

View File

@ -5,7 +5,7 @@ export * from "./activity-indicator-common";
export class ActivityIndicator extends ActivityIndicatorBase { export class ActivityIndicator extends ActivityIndicatorBase {
nativeView: android.widget.ProgressBar; nativeView: android.widget.ProgressBar;
public _createNativeView() { public createNativeView() {
const progressBar = new android.widget.ProgressBar(this._context); const progressBar = new android.widget.ProgressBar(this._context);
progressBar.setVisibility(android.view.View.INVISIBLE); progressBar.setVisibility(android.view.View.INVISIBLE);
progressBar.setIndeterminate(true); progressBar.setIndeterminate(true);

View File

@ -41,7 +41,7 @@ export class Button extends ButtonBase {
private _highlightedHandler: (args: TouchGestureEventData) => void; private _highlightedHandler: (args: TouchGestureEventData) => void;
public _createNativeView() { public createNativeView() {
initializeClickListener(); initializeClickListener();
const button = new android.widget.Button(this._context); const button = new android.widget.Button(this._context);
const clickListener = new ClickListener(this); const clickListener = new ClickListener(this);
@ -50,11 +50,11 @@ export class Button extends ButtonBase {
return button; return button;
} }
public _initNativeView(): void { public initNativeView(): void {
(<any>this.nativeView).clickListener.owner = this; (<any>this.nativeView).clickListener.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
(<any>this.nativeView).clickListener.owner = null; (<any>this.nativeView).clickListener.owner = null;
} }

View File

@ -202,24 +202,25 @@ export abstract class ViewBase extends Observable {
_tearDownUI(force?: boolean): void; _tearDownUI(force?: boolean): void;
/** /**
* Creates a native view * Creates a native view.
* Returns either android.view.View or UIView.
*/ */
_createNativeView(): Object; createNativeView(): Object;
/**
* Clean up references to the native view.
*/
_disposeNativeView(): void;
/** /**
* Initializes properties/listeners of the native view. * Initializes properties/listeners of the native view.
*/ */
_initNativeView(): void; initNativeView(): void;
/**
* Clean up references to the native view.
*/
disposeNativeView(): void;
/** /**
* Resets properties/listeners set to the native view. * Resets properties/listeners set to the native view.
*/ */
_resetNativeView(): void; resetNativeView(): void;
_isAddedToNativeVisualTree: boolean; _isAddedToNativeVisualTree: boolean;

View File

@ -126,7 +126,7 @@ function putNativeView(context: Object, view: ViewBase): void {
list.push(new WeakRef(view.nativeView)); list.push(new WeakRef(view.nativeView));
} }
export class ViewBase extends Observable implements ViewBaseDefinition { export abstract class ViewBase extends Observable implements ViewBaseDefinition {
public static loadedEvent = "loaded"; public static loadedEvent = "loaded";
public static unloadedEvent = "unloaded"; public static unloadedEvent = "unloaded";
@ -588,19 +588,19 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
} }
} }
public _createNativeView(): Object { public createNativeView(): Object {
return undefined; return undefined;
} }
public _disposeNativeView() { public disposeNativeView() {
// //
} }
public _initNativeView(): void { public initNativeView(): void {
// //
} }
public _resetNativeView(): void { public resetNativeView(): void {
if (this.nativeView && this.recycleNativeView && isAndroid) { if (this.nativeView && this.recycleNativeView && isAndroid) {
resetNativeView(this); resetNativeView(this);
} }
@ -627,7 +627,7 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
} }
if (!nativeView) { if (!nativeView) {
nativeView = <android.view.View>this._createNativeView(); nativeView = <android.view.View>this.createNativeView();
} }
this._androidView = this.nativeView = nativeView; this._androidView = this.nativeView = nativeView;
@ -659,14 +659,14 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
} }
} else { } else {
// TODO: Implement _createNativeView for iOS // TODO: Implement _createNativeView for iOS
this._createNativeView(); this.createNativeView();
if (!currentNativeView) { if (!currentNativeView) {
console.log(`${this.typeName} doesnt have NativeView !!!!! =================`); console.log(`${this.typeName} doesnt have NativeView !!!!! =================`);
} }
// this.nativeView = this._iosView = (<any>this)._nativeView; // this.nativeView = this._iosView = (<any>this)._nativeView;
} }
this._initNativeView(); this.initNativeView();
if (this.parent) { if (this.parent) {
let nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex); let nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex);
@ -695,7 +695,7 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
traceWrite(`${this}._tearDownUI(${force})`, traceCategories.VisualTreeEvents); traceWrite(`${this}._tearDownUI(${force})`, traceCategories.VisualTreeEvents);
} }
this._resetNativeView(); this.resetNativeView();
this.eachChild((child) => { this.eachChild((child) => {
child._tearDownUI(force); child._tearDownUI(force);
@ -714,7 +714,7 @@ export class ViewBase extends Observable implements ViewBaseDefinition {
} }
} }
this._disposeNativeView(); this.disposeNativeView();
this.nativeView = null; this.nativeView = null;
this._androidView = null; this._androidView = null;

View File

@ -471,7 +471,7 @@ export class View extends ViewCommon {
export class CustomLayoutView extends View implements CustomLayoutViewDefinition { export class CustomLayoutView extends View implements CustomLayoutViewDefinition {
nativeView: android.view.ViewGroup; nativeView: android.view.ViewGroup;
public _createNativeView() { public createNativeView() {
return new org.nativescript.widgets.ContentLayout(this._context); return new org.nativescript.widgets.ContentLayout(this._context);
} }

View File

@ -53,7 +53,7 @@ function initializeDateChangedListener(): void {
export class DatePicker extends DatePickerBase { export class DatePicker extends DatePickerBase {
nativeView: android.widget.DatePicker; nativeView: android.widget.DatePicker;
public _createNativeView() { public createNativeView() {
initializeDateChangedListener(); initializeDateChangedListener();
const picker = new android.widget.DatePicker(this._context); const picker = new android.widget.DatePicker(this._context);
picker.setCalendarViewShown(false); picker.setCalendarViewShown(false);
@ -63,11 +63,11 @@ export class DatePicker extends DatePickerBase {
return picker; return picker;
} }
public _initNativeView(): void { public initNativeView(): void {
(<any>this.nativeView).listener.owner = this; (<any>this.nativeView).listener.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
(<any>this.nativeView).listener.owner = null; (<any>this.nativeView).listener.owner = null;
} }

View File

@ -136,7 +136,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
public abstract _onReturnPress(): void; public abstract _onReturnPress(): void;
public _createNativeView() { public createNativeView() {
initializeEditTextListeners(); initializeEditTextListeners();
const editText = new android.widget.EditText(this._context); const editText = new android.widget.EditText(this._context);
this._configureEditText(editText); this._configureEditText(editText);
@ -149,7 +149,7 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
return editText; return editText;
} }
public _initNativeView(): void { public initNativeView(): void {
const nativeView = this.nativeView; const nativeView = this.nativeView;
(<any>nativeView).listener.owner = this; (<any>nativeView).listener.owner = this;
this._keyListenerCache = nativeView.getKeyListener(); this._keyListenerCache = nativeView.getKeyListener();
@ -168,12 +168,12 @@ export abstract class EditableTextBase extends EditableTextBaseCommon {
// this._android.removeTextChangedListener(this._editTextListeners); // this._android.removeTextChangedListener(this._editTextListeners);
// } // }
// } // }
// super._resetNativeView(); // super.resetNativeView();
// } // }
// public _disposeNativeView(force?: boolean) { // public _disposeNativeView(force?: boolean) {
// this._android = undefined; // this._android = undefined;
// super._disposeNativeView(); // super.disposeNativeView();
// } // }
public dismissSoftInput() { public dismissSoftInput() {

View File

@ -289,7 +289,7 @@ export class Frame extends FrameBase {
} }
} }
public _createNativeView() { public createNativeView() {
// TODO: probably memory leak. // TODO: probably memory leak.
// this._listener = new android.view.View.OnAttachStateChangeListener({ // this._listener = new android.view.View.OnAttachStateChangeListener({
// onViewAttachedToWindow: this.onNativeViewAttachedToWindow.bind(this), // onViewAttachedToWindow: this.onNativeViewAttachedToWindow.bind(this),
@ -303,17 +303,17 @@ export class Frame extends FrameBase {
return root; return root;
} }
public _initNativeView(): void { public initNativeView(): void {
this._android.rootViewGroup = this.nativeView; this._android.rootViewGroup = this.nativeView;
this._android.rootViewGroup.setId(this._containerViewId); this._android.rootViewGroup.setId(this._containerViewId);
// this._android.rootViewGroup.addOnAttachStateChangeListener(this._listener); // this._android.rootViewGroup.addOnAttachStateChangeListener(this._listener);
} }
// public _resetNativeView() { // public resetNativeView() {
// this._android.rootViewGroup.removeOnAttachStateChangeListener(this._listener); // this._android.rootViewGroup.removeOnAttachStateChangeListener(this._listener);
// } // }
public _disposeNativeView() { public disposeNativeView() {
// we should keep the reference to underlying native object, since frame can contain many pages. // we should keep the reference to underlying native object, since frame can contain many pages.
this._android.rootViewGroup = null; this._android.rootViewGroup = null;
} }

View File

@ -7,7 +7,7 @@ export * from "./html-view-common";
export class HtmlView extends HtmlViewBase { export class HtmlView extends HtmlViewBase {
nativeView: android.widget.TextView; nativeView: android.widget.TextView;
public _createNativeView() { public createNativeView() {
const textView = new android.widget.TextView(this._context); const textView = new android.widget.TextView(this._context);
// This makes the html <a href...> work // This makes the html <a href...> work
textView.setLinksClickable(true); textView.setLinksClickable(true);

View File

@ -82,7 +82,7 @@ export class Image extends ImageBase {
public decodeHeight = 0; public decodeHeight = 0;
public useCache = true; public useCache = true;
public _createNativeView() { public createNativeView() {
initializeImageLoadedListener(); initializeImageLoadedListener();
if (!imageFetcher) { if (!imageFetcher) {
initImageCache(this._context); initImageCache(this._context);
@ -96,11 +96,11 @@ export class Image extends ImageBase {
return imageView; return imageView;
} }
public _initNativeView(): void { public initNativeView(): void {
(<any>this.nativeView).listener.owner = this; (<any>this.nativeView).listener.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
(<any>this.nativeView).listener.owner = null; (<any>this.nativeView).listener.owner = null;
} }

View File

@ -13,14 +13,14 @@ export class Label extends TextBase implements LabelDefinition {
this.style.whiteSpace = value ? WhiteSpace.NORMAL : WhiteSpace.NO_WRAP; this.style.whiteSpace = value ? WhiteSpace.NORMAL : WhiteSpace.NO_WRAP;
} }
public _createNativeView() { public createNativeView() {
const textView = new android.widget.TextView(this._context); const textView = new android.widget.TextView(this._context);
textView.setSingleLine(true); textView.setSingleLine(true);
textView.setEllipsize(android.text.TextUtils.TruncateAt.END); textView.setEllipsize(android.text.TextUtils.TruncateAt.END);
return textView; return textView;
} }
public _initNativeView(): void { public initNativeView(): void {
const textView = this.nativeView; const textView = this.nativeView;
textView.setSingleLine(true); textView.setSingleLine(true);
// textView.setEllipsize(android.text.TextUtils.TruncateAt.END); // textView.setEllipsize(android.text.TextUtils.TruncateAt.END);

View File

@ -19,7 +19,7 @@ View.prototype[leftProperty.setNative] = makeNativeSetter<number>(function(this:
export class AbsoluteLayout extends AbsoluteLayoutBase { export class AbsoluteLayout extends AbsoluteLayoutBase {
nativeView: org.nativescript.widgets.AbsoluteLayout; nativeView: org.nativescript.widgets.AbsoluteLayout;
public _createNativeView() { public createNativeView() {
return new org.nativescript.widgets.AbsoluteLayout(this._context); return new org.nativescript.widgets.AbsoluteLayout(this._context);
} }
} }

View File

@ -34,7 +34,7 @@ View.prototype[dockProperty.setNative] = function(this: View, value: "left" | "t
export class DockLayout extends DockLayoutBase { export class DockLayout extends DockLayoutBase {
nativeView: org.nativescript.widgets.DockLayout; nativeView: org.nativescript.widgets.DockLayout;
public _createNativeView() { public createNativeView() {
return new org.nativescript.widgets.DockLayout(this._context); return new org.nativescript.widgets.DockLayout(this._context);
} }

View File

@ -79,11 +79,11 @@ const alignSelfMap = {
export class FlexboxLayout extends FlexboxLayoutBase { export class FlexboxLayout extends FlexboxLayoutBase {
nativeView: org.nativescript.widgets.FlexboxLayout; nativeView: org.nativescript.widgets.FlexboxLayout;
public _createNativeView() { public createNativeView() {
return new org.nativescript.widgets.FlexboxLayout(this._context); return new org.nativescript.widgets.FlexboxLayout(this._context);
} }
public _disposeNativeView() { public disposeNativeView() {
(<any>this.nativeView).invalidateOrdersCache(); (<any>this.nativeView).invalidateOrdersCache();
} }

View File

@ -52,17 +52,17 @@ export class ItemSpec extends ItemSpecBase {
export class GridLayout extends GridLayoutBase { export class GridLayout extends GridLayoutBase {
nativeView: org.nativescript.widgets.GridLayout; nativeView: org.nativescript.widgets.GridLayout;
public _createNativeView() { public createNativeView() {
return new org.nativescript.widgets.GridLayout(this._context); return new org.nativescript.widgets.GridLayout(this._context);
} }
public _initNativeView(): void { public initNativeView(): void {
// Update native GridLayout // Update native GridLayout
this.rowsInternal.forEach((itemSpec: ItemSpec, index, rows) => { this._onRowAdded(itemSpec); }, this); this.rowsInternal.forEach((itemSpec: ItemSpec, index, rows) => { this._onRowAdded(itemSpec); }, this);
this.columnsInternal.forEach((itemSpec: ItemSpec, index, rows) => { this._onColumnAdded(itemSpec); }, this); this.columnsInternal.forEach((itemSpec: ItemSpec, index, rows) => { this._onColumnAdded(itemSpec); }, this);
} }
public _disposeNativeView() { public disposeNativeView() {
// Update native GridLayout // Update native GridLayout
for (let i = this.rowsInternal.length; i--; i >= 0) { for (let i = this.rowsInternal.length; i--; i >= 0) {
const itemSpec = <ItemSpec>this.rowsInternal[i]; const itemSpec = <ItemSpec>this.rowsInternal[i];

View File

@ -41,18 +41,18 @@ export class Layout extends LayoutBase implements LayoutDefinition {
_measuredWidth: number; _measuredWidth: number;
_measuredHeight: number; _measuredHeight: number;
public _createNativeView() { public createNativeView() {
initializeNativeViewGroup(); initializeNativeViewGroup();
return new NativeViewGroup(this._context); return new NativeViewGroup(this._context);
} }
public _initNativeView(): void { public initNativeView(): void {
(<any>this.nativeView)[OWNER] = this; (<any>this.nativeView)[OWNER] = this;
} }
public _disposeNativeView() { public disposeNativeView() {
(<any>this.nativeView)[OWNER] = undefined; (<any>this.nativeView)[OWNER] = undefined;
super._disposeNativeView(); super.disposeNativeView();
} }
public measure(widthMeasureSpec: number, heightMeasureSpec: number): void { public measure(widthMeasureSpec: number, heightMeasureSpec: number): void {

View File

@ -5,7 +5,7 @@ export * from "./stack-layout-common";
export class StackLayout extends StackLayoutBase { export class StackLayout extends StackLayoutBase {
nativeView: org.nativescript.widgets.StackLayout; nativeView: org.nativescript.widgets.StackLayout;
public _createNativeView() { public createNativeView() {
return new org.nativescript.widgets.StackLayout(this._context); return new org.nativescript.widgets.StackLayout(this._context);
} }

View File

@ -5,7 +5,7 @@ export * from "./wrap-layout-common";
export class WrapLayout extends WrapLayoutBase { export class WrapLayout extends WrapLayoutBase {
nativeView: org.nativescript.widgets.WrapLayout; nativeView: org.nativescript.widgets.WrapLayout;
public _createNativeView() { public createNativeView() {
return new org.nativescript.widgets.WrapLayout(this._context); return new org.nativescript.widgets.WrapLayout(this._context);
} }

View File

@ -72,7 +72,7 @@ export class ListPicker extends ListPickerBase {
nativeView: android.widget.NumberPicker; nativeView: android.widget.NumberPicker;
private _selectorWheelPaint: android.graphics.Paint; private _selectorWheelPaint: android.graphics.Paint;
public _createNativeView() { public createNativeView() {
initializeNativeClasses(); initializeNativeClasses();
const picker = new android.widget.NumberPicker(this._context); const picker = new android.widget.NumberPicker(this._context);
@ -98,7 +98,7 @@ export class ListPicker extends ListPickerBase {
return picker; return picker;
} }
public _initNativeView(): void { public initNativeView(): void {
const nativeView = this.nativeView; const nativeView = this.nativeView;
this._selectorWheelPaint = getSelectorWheelPaint(nativeView); this._selectorWheelPaint = getSelectorWheelPaint(nativeView);
(<any>nativeView).formatter.owner = this; (<any>nativeView).formatter.owner = this;
@ -115,7 +115,7 @@ export class ListPicker extends ListPickerBase {
} }
} }
public _disposeNativeView() { public disposeNativeView() {
const nativeView = this.nativeView; const nativeView = this.nativeView;
(<any>nativeView).formatter.owner = null; (<any>nativeView).formatter.owner = null;
(<any>nativeView).valueChangedListener.owner = null; (<any>nativeView).valueChangedListener.owner = null;

View File

@ -49,7 +49,7 @@ export class ListView extends ListViewBase {
public _realizedItems = new Map<android.view.View, View>(); public _realizedItems = new Map<android.view.View, View>();
public _realizedTemplates = new Map<string, Map<android.view.View, View>>(); public _realizedTemplates = new Map<string, Map<android.view.View, View>>();
public _createNativeView() { public createNativeView() {
initializeItemClickListener(); initializeItemClickListener();
const listView = new android.widget.ListView(this._context); const listView = new android.widget.ListView(this._context);
@ -73,7 +73,7 @@ export class ListView extends ListViewBase {
return listView; return listView;
} }
public _initNativeView(): void { public initNativeView(): void {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
(<any>nativeView).itemClickListener.owner = this; (<any>nativeView).itemClickListener.owner = this;
const adapter = (<any>nativeView).adapter; const adapter = (<any>nativeView).adapter;
@ -85,13 +85,13 @@ export class ListView extends ListViewBase {
nativeView.setId(this._androidViewId); nativeView.setId(this._androidViewId);
} }
public _disposeNativeView() { public disposeNativeView() {
const nativeView = this.nativeView; const nativeView = this.nativeView;
nativeView.setAdapter(null); nativeView.setAdapter(null);
(<any>nativeView).itemClickListener.owner = null; (<any>nativeView).itemClickListener.owner = null;
(<any>nativeView).adapter.owner = null; (<any>nativeView).adapter.owner = null;
this.clearRealizedCells(); this.clearRealizedCells();
super._disposeNativeView(); super.disposeNativeView();
} }
public refresh() { public refresh() {

View File

@ -90,7 +90,7 @@ export class Page extends PageBase {
nativeView: org.nativescript.widgets.GridLayout; nativeView: org.nativescript.widgets.GridLayout;
private _isBackNavigation = false; private _isBackNavigation = false;
public _createNativeView() { public createNativeView() {
const layout = new org.nativescript.widgets.GridLayout(this._context); const layout = new org.nativescript.widgets.GridLayout(this._context);
layout.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto)); layout.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto));
layout.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star)); layout.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star));
@ -98,7 +98,7 @@ export class Page extends PageBase {
return layout; return layout;
} }
public _initNativeView(): void { public initNativeView(): void {
this.nativeView.setBackgroundColor(-1); // White color. this.nativeView.setBackgroundColor(-1); // White color.
} }

View File

@ -4,7 +4,7 @@ import { View } from "../core/view"
export class Placeholder extends View implements PlaceholderDefinition { export class Placeholder extends View implements PlaceholderDefinition {
public static creatingViewEvent = "creatingView"; public static creatingViewEvent = "creatingView";
public _createNativeView() { public createNativeView() {
let args = <CreateViewEventData>{ eventName: Placeholder.creatingViewEvent, object: this, view: undefined, context: this._context }; let args = <CreateViewEventData>{ eventName: Placeholder.creatingViewEvent, object: this, view: undefined, context: this._context };
this.notify(args); this.notify(args);
return <android.view.View>args.view; return <android.view.View>args.view;

View File

@ -10,7 +10,7 @@ const R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL = 0x01010078;
export class Progress extends ProgressBase { export class Progress extends ProgressBase {
nativeView: android.widget.ProgressBar; nativeView: android.widget.ProgressBar;
public _createNativeView() { public createNativeView() {
return new android.widget.ProgressBar(this._context, null, R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL); return new android.widget.ProgressBar(this._context, null, R_ATTR_PROGRESS_BAR_STYLE_HORIZONTAL);
} }

View File

@ -34,7 +34,7 @@ export class ProxyViewContainer extends LayoutBase implements ProxyViewContainer
return false; return false;
} }
public _createNativeView() { public createNativeView() {
return undefined; return undefined;
} }

View File

@ -70,7 +70,7 @@ export class ScrollView extends ScrollViewBase {
} }
} }
public _createNativeView() { public createNativeView() {
const nativeView = this.orientation === "horizontal" ? new org.nativescript.widgets.HorizontalScrollView(this._context) : new org.nativescript.widgets.VerticalScrollView(this._context); const nativeView = this.orientation === "horizontal" ? new org.nativescript.widgets.HorizontalScrollView(this._context) : new org.nativescript.widgets.VerticalScrollView(this._context);
if (this._androidViewId < 0) { if (this._androidViewId < 0) {
this._androidViewId = android.view.View.generateViewId(); this._androidViewId = android.view.View.generateViewId();

View File

@ -91,7 +91,7 @@ export class SearchBar extends SearchBarBase {
return result; return result;
} }
public _createNativeView() { public createNativeView() {
initializeNativeClasses(); initializeNativeClasses();
const nativeView = new android.widget.SearchView(this._context); const nativeView = new android.widget.SearchView(this._context);
nativeView.setIconified(false); nativeView.setIconified(false);
@ -107,13 +107,13 @@ export class SearchBar extends SearchBarBase {
return nativeView; return nativeView;
} }
public _initNativeView(): void { public initNativeView(): void {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
nativeView.closeListener.owner = this; nativeView.closeListener.owner = this;
nativeView.queryTextListener.owner = this; nativeView.queryTextListener.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
nativeView.closeListener.owner = null; nativeView.closeListener.owner = null;
nativeView.queryTextListener.owner = null; nativeView.queryTextListener.owner = null;

View File

@ -183,7 +183,7 @@ export class SegmentedBar extends SegmentedBarBase {
return !this._addingTab; return !this._addingTab;
} }
public _createNativeView() { public createNativeView() {
initializeNativeClasses(); initializeNativeClasses();
const context: android.content.Context = this._context; const context: android.content.Context = this._context;
@ -210,13 +210,13 @@ export class SegmentedBar extends SegmentedBarBase {
return nativeView; return nativeView;
} }
public _initNativeView(): void { public initNativeView(): void {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
nativeView.listener.owner = this; nativeView.listener.owner = this;
this._tabContentFactory = this._tabContentFactory || new TabContentFactory(this); this._tabContentFactory = this._tabContentFactory || new TabContentFactory(this);
} }
public _disposeNativeView() { public disposeNativeView() {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
nativeView.listener.owner = null; nativeView.listener.owner = null;
} }

View File

@ -48,7 +48,7 @@ export class Slider extends SliderBase {
_supressNativeValue: boolean; _supressNativeValue: boolean;
nativeView: android.widget.SeekBar; nativeView: android.widget.SeekBar;
public _createNativeView() { public createNativeView() {
initializeSeekBarChangeListener(); initializeSeekBarChangeListener();
const listener = new SeekBarChangeListener(this); const listener = new SeekBarChangeListener(this);
const nativeView = new android.widget.SeekBar(this._context); const nativeView = new android.widget.SeekBar(this._context);
@ -57,12 +57,12 @@ export class Slider extends SliderBase {
return nativeView; return nativeView;
} }
public _initNativeView(): void { public initNativeView(): void {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
nativeView.listener.owner = this; nativeView.listener.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
nativeView.listener.owner = null; nativeView.listener.owner = null;
} }

View File

@ -35,7 +35,7 @@ export class Switch extends SwitchBase {
nativeView: android.widget.Switch; nativeView: android.widget.Switch;
public checked: boolean; public checked: boolean;
public _createNativeView() { public createNativeView() {
initializeCheckedChangeListener(); initializeCheckedChangeListener();
const nativeView = new android.widget.Switch(this._context); const nativeView = new android.widget.Switch(this._context);
const listener = new CheckedChangeListener(this); const listener = new CheckedChangeListener(this);
@ -44,12 +44,12 @@ export class Switch extends SwitchBase {
return nativeView; return nativeView;
} }
public _initNativeView(): void { public initNativeView(): void {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
nativeView.listener.owner = this; nativeView.listener.owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
nativeView.listener.owner = null; nativeView.listener.owner = null;
} }

View File

@ -263,7 +263,7 @@ export class TabView extends TabViewBase {
} }
} }
public _createNativeView() { public createNativeView() {
initializeNativeClasses(); initializeNativeClasses();
if (traceEnabled()) { if (traceEnabled()) {
traceWrite("TabView._createUI(" + this + ");", traceCategory); traceWrite("TabView._createUI(" + this + ");", traceCategory);
@ -308,7 +308,7 @@ export class TabView extends TabViewBase {
return nativeView; return nativeView;
} }
public _initNativeView(): void { public initNativeView(): void {
if (this._androidViewId < 0) { if (this._androidViewId < 0) {
this._androidViewId = android.view.View.generateViewId(); this._androidViewId = android.view.View.generateViewId();
} }
@ -325,7 +325,7 @@ export class TabView extends TabViewBase {
(<any>this._pagerAdapter).owner = this; (<any>this._pagerAdapter).owner = this;
} }
public _disposeNativeView() { public disposeNativeView() {
// this._tabLayout.setItems(null, null); // this._tabLayout.setItems(null, null);
this._pagerAdapter.notifyDataSetChanged(); this._pagerAdapter.notifyDataSetChanged();
(<any>this._pagerAdapter).owner = null; (<any>this._pagerAdapter).owner = null;

View File

@ -51,13 +51,13 @@ export class TextBase extends TextBaseCommon {
nativeView: android.widget.TextView; nativeView: android.widget.TextView;
_defaultTransformationMethod: android.text.method.TransformationMethod; _defaultTransformationMethod: android.text.method.TransformationMethod;
public _initNativeView(): void { public initNativeView(): void {
this._defaultTransformationMethod = this.nativeView.getTransformationMethod(); this._defaultTransformationMethod = this.nativeView.getTransformationMethod();
super._initNativeView(); super.initNativeView();
} }
public _resetNativeView(): void { public resetNativeView(): void {
super._resetNativeView(); super.resetNativeView();
// We reset it here too because this could be changed by multiple properties - whiteSpace, secure, textTransform // We reset it here too because this could be changed by multiple properties - whiteSpace, secure, textTransform
this.nativeView.setTransformationMethod(this._defaultTransformationMethod); this.nativeView.setTransformationMethod(this._defaultTransformationMethod);
} }

View File

@ -10,9 +10,9 @@ export class TextField extends TextFieldBase {
editText.setHorizontallyScrolling(true); editText.setHorizontallyScrolling(true);
} }
public _initNativeView(): void { public initNativeView(): void {
// TODO: We should be able to reset it using only our properties. Check it first. // TODO: We should be able to reset it using only our properties. Check it first.
super._initNativeView(); super.initNativeView();
this.nativeView.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_NORMAL | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); this.nativeView.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_NORMAL | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
} }

View File

@ -9,9 +9,9 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
editText.setGravity(android.view.Gravity.TOP | android.view.Gravity.LEFT); editText.setGravity(android.view.Gravity.TOP | android.view.Gravity.LEFT);
} }
public _initNativeView(): void { public initNativeView(): void {
// TODO: We should be able to reset it using only our properties. Check it first. // TODO: We should be able to reset it using only our properties. Check it first.
super._initNativeView(); super.initNativeView();
this.nativeView.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_NORMAL | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE); this.nativeView.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_NORMAL | android.text.InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | android.text.InputType.TYPE_TEXT_FLAG_MULTI_LINE);
} }
} }

View File

@ -44,7 +44,7 @@ export class TimePicker extends TimePickerBase {
nativeView: android.widget.TimePicker; nativeView: android.widget.TimePicker;
updatingNativeValue: boolean; updatingNativeValue: boolean;
public _createNativeView() { public createNativeView() {
initializeTimeChangedListener(); initializeTimeChangedListener();
const nativeView = new android.widget.TimePicker(this._context); const nativeView = new android.widget.TimePicker(this._context);
const listener = new TimeChangedListener(this); const listener = new TimeChangedListener(this);
@ -54,7 +54,7 @@ export class TimePicker extends TimePickerBase {
return nativeView; return nativeView;
} }
public _initNativeView(): void { public initNativeView(): void {
const nativeView: any = this.nativeView; const nativeView: any = this.nativeView;
nativeView.listener.owner = this; nativeView.listener.owner = this;

View File

@ -88,7 +88,7 @@ function initializeWebViewClient(): void {
export class WebView extends WebViewBase { export class WebView extends WebViewBase {
nativeView: android.webkit.WebView; nativeView: android.webkit.WebView;
public _createNativeView() { public createNativeView() {
initializeWebViewClient(); initializeWebViewClient();
const nativeView = new android.webkit.WebView(this._context); const nativeView = new android.webkit.WebView(this._context);
@ -100,18 +100,18 @@ export class WebView extends WebViewBase {
return nativeView; return nativeView;
} }
public _initNativeView(): void { public initNativeView(): void {
(<any>this.nativeView).client.owner = this; (<any>this.nativeView).client.owner = this;
} }
public _resetNativeView() { public resetNativeView() {
const nativeView = this.nativeView; const nativeView = this.nativeView;
if (nativeView) { if (nativeView) {
nativeView.destroy(); nativeView.destroy();
} }
(<any>nativeView).client.owner = null; (<any>nativeView).client.owner = null;
super._resetNativeView(); super.resetNativeView();
} }
public _loadFileOrResource(path: string, content: string) { public _loadFileOrResource(path: string, content: string) {