Reverted the changes made with commit 700818d (Resolves Issue #1223). Use this to fix visual glitches: view.android.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);

This commit is contained in:
Rossen Hristov
2015-12-12 15:14:04 +02:00
parent 55cbbb977a
commit f732224248
3 changed files with 15 additions and 39 deletions

View File

@ -25,8 +25,11 @@ export function pageLoaded(args: observable.EventData) {
export function onSetOpacity(args: observable.EventData) {
var newOpacity = opacitySlider.value / 100;
container._eachChildView((childView: view.View) => {
childView.opacity = newOpacity;
container._eachChildView((view: view.View) => {
if (view.android) {
view.android.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
}
view.opacity = newOpacity;
return true;
});
}
@ -35,9 +38,12 @@ var animationSet: animationModule.Animation;
export function onAnimateOpacity(args: observable.EventData) {
var newOpacity = opacitySlider.value / 100;
var animationDefinitions = new Array<animationModule.AnimationDefinition>();
container._eachChildView((childView: view.View) => {
container._eachChildView((view: view.View) => {
if (view.android) {
view.android.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
}
animationDefinitions.push({
target: childView,
target: view,
opacity: newOpacity,
duration: 5000
});

View File

@ -159,18 +159,11 @@ export class Animation extends common.Animation implements definition.Animation
case common.Properties.opacity:
originalValue1 = nativeView.getAlpha();
nativeArray = java.lang.reflect.Array.newInstance(floatType, 2);
nativeArray[0] = originalValue1;
nativeArray[1] = propertyAnimation.value;
animator = android.animation.ValueAnimator.ofFloat(nativeArray);
animator.addUpdateListener(new android.animation.ValueAnimator.AnimatorUpdateListener({
onAnimationUpdate(animator: android.animation.ValueAnimator) {
propertyAnimation.target.opacity = (<java.lang.Float>animator.getAnimatedValue()).floatValue();
}
}));
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = propertyAnimation.value; }));
propertyResetCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = originalValue1; }));
animators.push(animator);
nativeArray = java.lang.reflect.Array.newInstance(floatType, 1);
nativeArray[0] = propertyAnimation.value;
propertyUpdateCallbacks.push(checkAnimation(() => { propertyAnimation.target.opacity = propertyAnimation.value }));
propertyResetCallbacks.push(checkAnimation(() => { nativeView.setAlpha(originalValue1); }));
animators.push(android.animation.ObjectAnimator.ofFloat(nativeView, "alpha", nativeArray));
break;
case common.Properties.backgroundColor:

View File

@ -341,25 +341,6 @@ export class ImageStyler implements definition.stylers.Styler {
onBackgroundOrBorderPropertyChanged(view);
}
//Opacity methods
private static setOpacityProperty(view: view.View, newValue: any) {
ImageStyler._setOpacity(view, newValue);
}
private static resetOpacityProperty(view: view.View, nativeValue: any) {
ImageStyler._setOpacity(view, 1.0);
}
private static _setOpacity(view: view.View, value: any) {
let opacity = float(value);
let nativeView = <android.view.View>view._nativeView;
nativeView.setAlpha(opacity);
let background = nativeView.getBackground();
if (background) {
background.setAlpha(opacity);
}
}
public static registerHandlers() {
// Use the same handler for all background/border properties
// Note: There is no default value getter - the default value is handled in onBackgroundOrBorderPropertyChanged
@ -371,10 +352,6 @@ export class ImageStyler implements definition.stylers.Styler {
style.registerHandler(style.borderWidthProperty, new stylersCommon.StylePropertyChangedHandler(
ImageStyler.setBorderWidthProperty,
ImageStyler.resetBorderWidthProperty), "Image");
style.registerHandler(style.opacityProperty, new stylersCommon.StylePropertyChangedHandler(
ImageStyler.setOpacityProperty,
ImageStyler.resetOpacityProperty), "Image");
}
}