1515import ti .modules .titanium .ui .WindowProxy ;
1616import android .support .v4 .app .ActionBarDrawerToggle ;
1717import android .support .v4 .app .FragmentManager ;
18+ import android .support .v4 .app .FragmentTransaction ;
1819import android .support .v4 .widget .DrawerLayout ;
1920import android .support .v4 .widget .DrawerLayout .LayoutParams ;
2021import android .support .v7 .app .ActionBarActivity ;
@@ -418,7 +419,7 @@ private void initRightDrawer() {
418419 /**
419420 * centerView 변경
420421 */
421- private void replaceCenterView (TiViewProxy viewProxy ) {
422+ public void replaceCenterView (TiViewProxy viewProxy , boolean backstack ) {
422423 if (viewProxy == this .centerView ) {
423424 Log .d (TAG , "centerView was not changed" );
424425 return ;
@@ -440,14 +441,24 @@ private void replaceCenterView(TiViewProxy viewProxy) {
440441 // since only map uses TiUIFragment, here we check if view is a map,
441442 // then we add the fragment directly.
442443 if (contentView instanceof TiUIFragment ) {
443- fragmentManager .beginTransaction ().replace (id_content_frame , ((TiUIFragment )contentView ).getFragment ())
444- .commit ();
444+ FragmentTransaction ft = fragmentManager .beginTransaction ();
445+ ft .replace (id_content_frame , ((TiUIFragment )contentView ).getFragment ());
446+ if (backstack ){
447+ Log .d (TAG , "adding Fragment to backstack" );
448+ ft .addToBackStack (name );
449+ }
450+ ft .commit ();
445451 } else {
446452 View view = contentView .getOuterView ();
447453 ContentWrapperFragment fragment = new ContentWrapperFragment ();
448454 fragment .setContentView (view );
449- fragmentManager .beginTransaction ().replace (id_content_frame , fragment )
450- .commit ();
455+ FragmentTransaction ft = fragmentManager .beginTransaction ();
456+ ft .replace (id_content_frame , fragment );
457+ if (backstack ){
458+ Log .d (TAG , "adding Fragment to backstack" );
459+ ft .addToBackStack (name );
460+ }
461+ ft .commit ();
451462 }
452463
453464 this .centerView = viewProxy ;
@@ -497,7 +508,6 @@ public void processProperties(KrollDict d) {
497508 if (rightView instanceof WindowProxy )
498509 throw new IllegalStateException (
499510 "[ERROR] Cannot add window as a child view of other window" );
500- //
501511 this .rightView = (TiViewProxy ) rightView ;
502512 this .initRightDrawer ();
503513 this .filter .addView (getNativeView (this .rightView ));
@@ -511,8 +521,7 @@ public void processProperties(KrollDict d) {
511521 if (centerView instanceof WindowProxy )
512522 throw new IllegalStateException (
513523 "[ERROR] Cannot use window as a child view of other window" );
514- //
515- replaceCenterView ((TiViewProxy ) centerView );
524+ replaceCenterView ((TiViewProxy ) centerView , false );
516525 } else {
517526 Log .e (TAG , "[ERROR] Invalid type for centerView" );
518527 }
@@ -599,7 +608,7 @@ public void propertyChanged(String key, Object oldValue, Object newValue,
599608 this .rightView = newProxy ;
600609 } else if (key .equals (PROPERTY_CENTER_VIEW )) {
601610 TiViewProxy newProxy = (TiViewProxy ) newValue ;
602- replaceCenterView (newProxy );
611+ replaceCenterView (newProxy , false );
603612 } else if (key .equals (PROPERTY_LEFT_VIEW_WIDTH )) {
604613 menuWidth = getDevicePixels (newValue );
605614
0 commit comments