fix(android): undefined right-hand side of instance of

Picked from master:
fd5236f1b3
This commit is contained in:
Nathan Walker
2020-09-04 08:12:50 -07:00
parent fb2cbead94
commit bd4184e78b

View File

@ -17,8 +17,16 @@ export * from "./flexbox-layout-common";
let widgetFlexboxLayout: typeof org.nativescript.widgets.FlexboxLayout; let widgetFlexboxLayout: typeof org.nativescript.widgets.FlexboxLayout;
let widgetLayoutParams: typeof org.nativescript.widgets.FlexboxLayout.LayoutParams; let widgetLayoutParams: typeof org.nativescript.widgets.FlexboxLayout.LayoutParams;
function ensureNativeTypes() {
if (!widgetFlexboxLayout) {
widgetFlexboxLayout = org.nativescript.widgets.FlexboxLayout;
widgetLayoutParams = widgetFlexboxLayout.LayoutParams;
}
}
function makeNativeSetter<T>(setter: (lp: org.nativescript.widgets.FlexboxLayout.LayoutParams, value: T) => void) { function makeNativeSetter<T>(setter: (lp: org.nativescript.widgets.FlexboxLayout.LayoutParams, value: T) => void) {
return function (this: View, value: T) { return function (this: View, value: T) {
ensureNativeTypes();
const nativeView: android.view.View = this.nativeViewProtected; const nativeView: android.view.View = this.nativeViewProtected;
const lp = nativeView.getLayoutParams() || new widgetLayoutParams(); const lp = nativeView.getLayoutParams() || new widgetLayoutParams();
if (lp instanceof widgetLayoutParams) { if (lp instanceof widgetLayoutParams) {
@ -86,10 +94,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
constructor() { constructor() {
super(); super();
if (!widgetFlexboxLayout) { ensureNativeTypes();
widgetFlexboxLayout = org.nativescript.widgets.FlexboxLayout;
widgetLayoutParams = widgetFlexboxLayout.LayoutParams;
}
} }
public createNativeView() { public createNativeView() {