fix(android): back navigation on app suspend/resume (#6489)

This commit is contained in:
Manol Donev
2018-11-02 17:31:52 +02:00
committed by GitHub
parent 2933a9a934
commit fac970e753

View File

@ -25,10 +25,10 @@ import { createViewFromEntry } from "../builder";
export * from "./frame-common"; export * from "./frame-common";
interface AnimatorState { interface AnimatorState {
enterAnimator: android.animation.Animator; enterAnimator: any;
exitAnimator: android.animation.Animator; exitAnimator: any;
popEnterAnimator: android.animation.Animator; popEnterAnimator: any;
popExitAnimator: android.animation.Animator; popExitAnimator: any;
transitionName: string; transitionName: string;
} }
@ -306,10 +306,8 @@ export class Frame extends FrameBase {
// restore cached animation settings if we just completed simulated first navigation (no animation) // restore cached animation settings if we just completed simulated first navigation (no animation)
if (this._cachedAnimatorState) { if (this._cachedAnimatorState) {
restoreAnimatorState(this._currentEntry, this._cachedAnimatorState); restoreAnimatorState(this._currentEntry, this._cachedAnimatorState);
this._cachedAnimatorState = null; this._cachedAnimatorState = null;
} }
} }
public onBackPressed(): boolean { public onBackPressed(): boolean {
@ -503,13 +501,26 @@ export class Frame extends FrameBase {
} }
} }
function cloneExpandedAnimator(expandedAnimator: any) {
if (!expandedAnimator) {
return null;
}
const clone = expandedAnimator.clone();
clone.entry = expandedAnimator.entry;
clone.transitionType = expandedAnimator.transitionType;
return clone;
}
function getAnimatorState(entry: BackstackEntry): AnimatorState { function getAnimatorState(entry: BackstackEntry): AnimatorState {
const expandedEntry = <any>entry; const expandedEntry = <any>entry;
const animatorState = <AnimatorState>{}; const animatorState = <AnimatorState>{};
animatorState.enterAnimator = expandedEntry.enterAnimator;
animatorState.exitAnimator = expandedEntry.exitAnimator; animatorState.enterAnimator = cloneExpandedAnimator(expandedEntry.enterAnimator);
animatorState.popEnterAnimator = expandedEntry.popEnterAnimator; animatorState.exitAnimator = cloneExpandedAnimator(expandedEntry.exitAnimator);
animatorState.popExitAnimator = expandedEntry.popExitAnimator; animatorState.popEnterAnimator = cloneExpandedAnimator(expandedEntry.popEnterAnimator);
animatorState.popExitAnimator = cloneExpandedAnimator(expandedEntry.popExitAnimator);
animatorState.transitionName = expandedEntry.transitionName; animatorState.transitionName = expandedEntry.transitionName;
return animatorState; return animatorState;