From 8da85629fe15a0a4aa7bf3b6a862af8472fa3f54 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 3 Aug 2016 18:10:25 +0300 Subject: [PATCH] z-index handler added only for API 21+ --- tns-core-modules/ui/core/view.android.ts | 27 +++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tns-core-modules/ui/core/view.android.ts b/tns-core-modules/ui/core/view.android.ts index 383da674a..9b2364954 100644 --- a/tns-core-modules/ui/core/view.android.ts +++ b/tns-core-modules/ui/core/view.android.ts @@ -10,6 +10,7 @@ import style = require("ui/styling/style"); import enums = require("ui/enums"); import background = require("ui/styling/background"); import {CommonLayoutParams, Thickness} from "ui/styling/style"; +import {device} from "platform"; global.moduleMerge(viewCommon, exports); @@ -51,6 +52,8 @@ function onIsUserInteractionEnabledPropertyChanged(data: dependencyObservable.Pr } (viewCommon.View.isUserInteractionEnabledProperty.metadata).onSetNativeValue = onIsUserInteractionEnabledPropertyChanged; +let styleHandlersInitialized: boolean; + export class View extends viewCommon.View { private _disableUserInteractionListener: android.view.View.OnTouchListener = new android.view.View.OnTouchListener({ onTouch: function (view: android.view.View, event: android.view.MotionEvent) { @@ -58,6 +61,14 @@ export class View extends viewCommon.View { } }); + constructor() { + super(); + if (!styleHandlersInitialized) { + styleHandlersInitialized = true; + ViewStyler.registerHandlers(); + } + } + public _updateOnTouchListener(isUserInteractionEnabled: boolean) { // User interaction is disabled -- we stop it and we do not care whether someone wants to listen for gestures. if (!isUserInteractionEnabled) { @@ -784,12 +795,12 @@ export class ViewStyler implements style.Styler { style.registerHandler(style.translateYProperty, new style.StylePropertyChangedHandler( ViewStyler.setTranslateYProperty, ViewStyler.resetTranslateYProperty)); - - style.registerHandler(style.zIndexProperty, new style.StylePropertyChangedHandler( - ViewStyler.setZIndexProperty, - ViewStyler.resetZIndexProperty, - ViewStyler.getZIndexProperty)); + + if (parseInt(device.sdkVersion, 10) >= 21) { + style.registerHandler(style.zIndexProperty, new style.StylePropertyChangedHandler( + ViewStyler.setZIndexProperty, + ViewStyler.resetZIndexProperty, + ViewStyler.getZIndexProperty)); + } } -} - -ViewStyler.registerHandlers(); +} \ No newline at end of file