Merge pull request #2547 from NativeScript/hhristov/zindex-fix-lower-apis

z-index handler added only for API 21+
This commit is contained in:
SvetoslavTsenov
2016-08-03 18:48:36 +03:00
committed by GitHub

View File

@@ -10,6 +10,7 @@ import style = require("ui/styling/style");
import enums = require("ui/enums"); import enums = require("ui/enums");
import background = require("ui/styling/background"); import background = require("ui/styling/background");
import {CommonLayoutParams, Thickness} from "ui/styling/style"; import {CommonLayoutParams, Thickness} from "ui/styling/style";
import {device} from "platform";
global.moduleMerge(viewCommon, exports); global.moduleMerge(viewCommon, exports);
@@ -51,6 +52,8 @@ function onIsUserInteractionEnabledPropertyChanged(data: dependencyObservable.Pr
} }
(<proxy.PropertyMetadata>viewCommon.View.isUserInteractionEnabledProperty.metadata).onSetNativeValue = onIsUserInteractionEnabledPropertyChanged; (<proxy.PropertyMetadata>viewCommon.View.isUserInteractionEnabledProperty.metadata).onSetNativeValue = onIsUserInteractionEnabledPropertyChanged;
let styleHandlersInitialized: boolean;
export class View extends viewCommon.View { export class View extends viewCommon.View {
private _disableUserInteractionListener: android.view.View.OnTouchListener = new android.view.View.OnTouchListener({ private _disableUserInteractionListener: android.view.View.OnTouchListener = new android.view.View.OnTouchListener({
onTouch: function (view: android.view.View, event: android.view.MotionEvent) { 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) { public _updateOnTouchListener(isUserInteractionEnabled: boolean) {
// User interaction is disabled -- we stop it and we do not care whether someone wants to listen for gestures. // User interaction is disabled -- we stop it and we do not care whether someone wants to listen for gestures.
if (!isUserInteractionEnabled) { if (!isUserInteractionEnabled) {
@@ -785,11 +796,11 @@ export class ViewStyler implements style.Styler {
ViewStyler.setTranslateYProperty, ViewStyler.setTranslateYProperty,
ViewStyler.resetTranslateYProperty)); ViewStyler.resetTranslateYProperty));
if (parseInt(device.sdkVersion, 10) >= 21) {
style.registerHandler(style.zIndexProperty, new style.StylePropertyChangedHandler( style.registerHandler(style.zIndexProperty, new style.StylePropertyChangedHandler(
ViewStyler.setZIndexProperty, ViewStyler.setZIndexProperty,
ViewStyler.resetZIndexProperty, ViewStyler.resetZIndexProperty,
ViewStyler.getZIndexProperty)); ViewStyler.getZIndexProperty));
} }
}
} }
ViewStyler.registerHandlers();