This commit is contained in:
atanasovg
2016-03-03 18:03:27 +02:00
parent 857b5582b0
commit 66936ff0c4
3 changed files with 16 additions and 4 deletions

View File

@ -1,7 +1,6 @@
import bindable = require("ui/core/bindable");
import dependencyObservable = require("ui/core/dependency-observable");
import definition = require("ui/core/proxy");
import * as platform from "platform";
import * as types from "utils/types";
import * as observable from "data/observable";
@ -71,13 +70,20 @@ export class ProxyObject extends bindable.Bindable implements definition.ProxyOb
this._eachSetProperty(eachPropertyCallback);
}
/**
* Checks whether the proxied native object has been created and properties may be applied to it.
*/
protected _canApplyNativeProperty(): boolean {
return false;
}
private _trySetNativeValue(property: dependencyObservable.Property, oldValue?:any, newValue?: any) {
if (this._updatingJSPropertiesDict[property.name]) {
// This is the case when a property has changed from the native side directly and we have received the "_onPropertyChanged" event while synchronizing our local cache
return;
}
if (platform.device.os === platform.platformNames.android && !this.android) {
if (!this._canApplyNativeProperty()) {
// in android we have lazy loading and we do not have a native widget created yet, do not call the onSetNativeValue callback
// properties will be synced when the widget is created
return;

View File

@ -1165,4 +1165,9 @@ export class View extends ProxyObject implements definition.View {
public _onStylePropertyChanged(property: Property): void {
//
}
protected _canApplyNativeProperty(): boolean {
// Check for a valid _nativeView instance
return !!this._nativeView;
}
}

View File

@ -47,11 +47,12 @@ export class Source {
}
}
export class ScopeError implements Error {
export class ScopeError extends Error {
private _child: Error;
private _message: string;
constructor(child: Error, message?: string) {
constructor(child: Error, message?: string) {
super(message);
if (!child) {
throw new Error("Required child error!");
}