mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
Merge pull request #2211 from NativeScript/layer-type
Fixed: Android layerType should not be changed if there is no need
This commit is contained in:
@ -238,8 +238,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;
|
||||
}
|
||||
@ -278,14 +284,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
|
||||
@ -300,9 +304,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user