mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed: Android layerType should not be changed if there is no need
Resolves #1899
This commit is contained in:
@@ -225,8 +225,14 @@ export module ad {
|
||||
|
||||
var _defaultBackgrounds = new Map<string, android.graphics.drawable.Drawable>();
|
||||
|
||||
interface CacheLayerType {
|
||||
layerType: number;
|
||||
}
|
||||
|
||||
export function onBackgroundOrBorderPropertyChanged(v: view.View) {
|
||||
var nativeView = <android.view.View>v._nativeView;
|
||||
var cache = <CacheLayerType>v._nativeView;
|
||||
|
||||
if (!nativeView) {
|
||||
return;
|
||||
}
|
||||
@@ -265,14 +271,12 @@ export module ad {
|
||||
bkg.background = backgroundValue;
|
||||
bkg.clipPath = clipPathValue;
|
||||
|
||||
if (getSDK() < 18) {
|
||||
if ((v.borderWidth !== 0 || v.borderRadius !== 0 || clipPathValue) && getSDK() < 18) {
|
||||
// Switch to software because of unsupported canvas methods if hardware acceleration is on:
|
||||
// http://developer.android.com/guide/topics/graphics/hardware-accel.html
|
||||
cache.layerType = nativeView.getLayerType();
|
||||
nativeView.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
else {
|
||||
nativeView.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// reset the value with the default native value
|
||||
@@ -287,9 +291,10 @@ export module ad {
|
||||
}
|
||||
}
|
||||
|
||||
if (getSDK() < 18) {
|
||||
// Reset layer type to hardware
|
||||
nativeView.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
|
||||
if (cache.layerType !== undefined) {
|
||||
// Reset layer type
|
||||
nativeView.setLayerType(cache.layerType, null);
|
||||
cache.layerType = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -405,9 +405,11 @@ function isPaddingValid(value: number): boolean {
|
||||
|
||||
var supportedPaths = ["rect", "circle", "ellipse", "polygon"];
|
||||
function isClipPathValid(value: string): boolean {
|
||||
if (!value){
|
||||
return true;
|
||||
}
|
||||
var functionName = value.substring(0, value.indexOf("(")).trim();
|
||||
|
||||
return supportedPaths.indexOf(functionName) !== -1 || value === "";
|
||||
return supportedPaths.indexOf(functionName) !== -1;
|
||||
}
|
||||
|
||||
function isMarginValid(value: number): boolean {
|
||||
@@ -921,7 +923,7 @@ export class Style extends DependencyObservable implements styling.Style {
|
||||
}
|
||||
|
||||
private _applyStyleProperty(property: Property, newValue: any) {
|
||||
|
||||
|
||||
if (!this._view._shouldApplyStyleHandlers()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user