@@ -209,8 +209,12 @@ export class Frame extends FrameBase {
209209 }
210210
211211 public _onRootViewReset ( ) : void {
212- this . disposeCurrentFragment ( ) ;
213212 super . _onRootViewReset ( ) ;
213+
214+ // call this AFTER the super call to ensure descendants apply their rootview-reset logic first
215+ // i.e. in a scenario with nested frames / frame with tabview let the descendandt cleanup the inner
216+ // fragments first, and then cleanup the parent fragments
217+ this . disposeCurrentFragment ( ) ;
214218 }
215219
216220 onUnloaded ( ) {
@@ -223,11 +227,6 @@ export class Frame extends FrameBase {
223227 }
224228
225229 private disposeCurrentFragment ( ) : void {
226- // when interacting with nested fragments it seems Android is smart enough
227- // to automatically remove child fragments when parent fragment is removed;
228- // however, we must add a fragment.isAdded() guard as our logic will try to
229- // explicitly remove the already removed child fragment causing an
230- // IllegalStateException: Fragment has not been attached yet.
231230 if ( ! this . _currentEntry ||
232231 ! this . _currentEntry . fragment ||
233232 ! this . _currentEntry . fragment . isAdded ( ) ) {
@@ -742,7 +741,13 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
742741 }
743742
744743 @profile
745- public onCreateAnimator ( fragment : android . support . v4 . app . Fragment , transit : number , enter : boolean , nextAnim : number , superFunc : Function ) : android . animation . Animator {
744+ public onCreateAnimator ( fragment : org . nativescript . widgets . FragmentBase , transit : number , enter : boolean , nextAnim : number , superFunc : Function ) : android . animation . Animator {
745+ // HACK: FragmentBase class MUST handle removing nested fragment scenario to workaround
746+ // https://code.google.com/p/android/issues/detail?id=55228
747+ if ( ! enter && fragment . getRemovingParentFragment ( ) ) {
748+ return superFunc . call ( fragment , transit , enter , nextAnim ) ;
749+ }
750+
746751 let nextAnimString : string ;
747752 switch ( nextAnim ) {
748753 case AnimationType . enterFakeResourceId : nextAnimString = "enter" ; break ;
0 commit comments