Fixed: animations crash on Android

This commit is contained in:
Tsvetan Raikov
2016-04-12 14:29:46 +03:00
parent a61dffa3a3
commit df2ad08773
2 changed files with 15 additions and 8 deletions

View File

@ -32,9 +32,9 @@ export class Animation extends common.Animation implements definition.Animation
private _propertyUpdateCallbacks: Array<Function>; private _propertyUpdateCallbacks: Array<Function>;
private _propertyResetCallbacks: Array<Function>; private _propertyResetCallbacks: Array<Function>;
private _valueSource: number; private _valueSource: number;
public play(): definition.AnimationPromise { public play(): definition.AnimationPromise {
var animationFinishedPromise = super.play(); let animationFinishedPromise = super.play();
let i: number; let i: number;
let length: number; let length: number;
@ -58,11 +58,13 @@ export class Animation extends common.Animation implements definition.Animation
this._animatorSet = new android.animation.AnimatorSet(); this._animatorSet = new android.animation.AnimatorSet();
this._animatorSet.addListener(this._animatorListener); this._animatorSet.addListener(this._animatorListener);
if (this._playSequentially) { if (length > 0) {
this._animatorSet.playSequentially(this._nativeAnimatorsArray); if (this._playSequentially) {
} this._animatorSet.playSequentially(this._nativeAnimatorsArray);
else { }
this._animatorSet.playTogether(this._nativeAnimatorsArray); else {
this._animatorSet.playTogether(this._nativeAnimatorsArray);
}
} }
trace.write("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), trace.categories.Animation); trace.write("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), trace.categories.Animation);
@ -127,6 +129,11 @@ export class Animation extends common.Animation implements definition.Animation
} }
private _createAnimators(propertyAnimation: common.PropertyAnimation): void { private _createAnimators(propertyAnimation: common.PropertyAnimation): void {
if (!propertyAnimation.target._nativeView) {
return;
}
trace.write("Creating ObjectAnimator(s) for animation: " + common.Animation._getAnimationInfo(propertyAnimation) + "...", trace.categories.Animation); trace.write("Creating ObjectAnimator(s) for animation: " + common.Animation._getAnimationInfo(propertyAnimation) + "...", trace.categories.Animation);
if (types.isNullOrUndefined(propertyAnimation.target)) { if (types.isNullOrUndefined(propertyAnimation.target)) {

View File

@ -88,7 +88,7 @@ export class CssSelector {
} }
} }
}); });
if (this.animations && view.isLoaded) { if (this.animations && view.isLoaded && view._nativeView !== undefined) {
for (let animationInfo of this.animations) { for (let animationInfo of this.animations) {
let animation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animationInfo, modifier); let animation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animationInfo, modifier);
if (animation) { if (animation) {