diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardFrag.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardFrag.java index c593d0a6f..506d79700 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardFrag.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardFrag.java @@ -32,9 +32,8 @@ public class BoardFrag extends XWFragment implements Delegator { @Override public void onCreate( Bundle savedInstanceState ) { - DbgUtils.logf( "GamesListFrag.onCreate()" ); m_dlgt = new BoardDelegate( this, savedInstanceState ); - super.onCreate( m_dlgt, savedInstanceState, R.layout.board ); + super.onCreate( m_dlgt, savedInstanceState ); } @Override diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/FragActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/FragActivity.java index 84c69c758..3d09f5ac0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/FragActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/FragActivity.java @@ -58,22 +58,13 @@ public class FragActivity extends FragmentActivity m_root = (LinearLayout)findViewById( R.id.main_container ); getSupportFragmentManager().addOnBackStackChangedListener( this ); - int orientation = getResources().getConfiguration().orientation; m_maxPanes = maxPanes(); // Nothing to do if we're restarting - if (savedInstanceState == null) { - DbgUtils.logf( "calling new GamesListFrag()" ); - GamesListFrag glf = new GamesListFrag(); - DbgUtils.logf( "new GamesListFrag() done" ); - + if ( savedInstanceState == null ) { // In case this activity was started with special instructions from an Intent, // pass the Intent's extras to the fragment as arguments - glf.setArguments( getIntent().getExtras() ); - - DbgUtils.logf( "calling addFragment(glf)" ); - addFragment( glf ); - DbgUtils.logf( "addFragment(glf) DONE" ); + addFragmentImpl( new GamesListFrag(), getIntent().getExtras() ); } } @@ -120,37 +111,25 @@ public class FragActivity extends FragmentActivity } } - ////////////////////////////////////////////////////////////////////// - // GameListDelegate.DlgtOwner - ////////////////////////////////////////////////////////////////////// - public static void launchGame( long rowid, boolean invited ) - { - DbgUtils.logf( "FragActivity.launchGame(%d)", rowid ); - Bundle args = GameUtils.makeLaunchExtras( rowid, invited ); - BoardFrag bf = new BoardFrag(); - bf.setArguments( args ); - getThis().addFragment( bf ); - } - - public void launchDictFrag( Bundle args ) - { - // DictBrowseFrag dbf = new DictBrowseFrag(); - // dbf.setArguments( args ); - // addFragment( dbf ); - } + // public void launchDictFrag( Bundle args ) + // { + // // DictBrowseFrag dbf = new DictBrowseFrag(); + // // dbf.setArguments( args ); + // // addFragment( dbf ); + // } protected void popFragment( Fragment frag ) { getSupportFragmentManager().popBackStack(); } - protected void addFragment( Fragment fragment, Bundle bundle ) + private void addFragmentImpl( Fragment fragment, Bundle bundle ) { fragment.setArguments( bundle ); - addFragment( fragment ); + addFragmentImpl( fragment ); } - protected void addFragment( Fragment fragment ) + private void addFragmentImpl( Fragment fragment ) { String newName = fragment.getClass().getName(); boolean replace = false; @@ -240,4 +219,14 @@ public class FragActivity extends FragmentActivity return s_this; } + public static void launchGame( long rowid, boolean invited ) + { + Bundle args = GameUtils.makeLaunchExtras( rowid, invited ); + addFragment( new BoardFrag(), args ); + } + + public static void addFragment( Fragment fragment, Bundle bundle ) + { + getThis().addFragmentImpl( fragment, bundle ); + } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameDelegate.java index a69e6bb29..707178720 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameDelegate.java @@ -476,9 +476,14 @@ public class NewGameDelegate extends DelegateBase { public static void startActivity( Activity parent, long groupID ) { - Intent intent = new Intent( parent, NewGameActivity.class ); - intent.putExtra( GROUPID_EXTRA, groupID ); - parent.startActivity( intent ); + Bundle extras = new Bundle(); + extras.putLong( GROUPID_EXTRA, groupID ); + if ( parent instanceof FragActivity ) { + FragActivity.addFragment( new NewGameFrag(), extras ); + } else { + Intent intent = new Intent( parent, NewGameActivity.class ); + intent.putExtras( extras ); + parent.startActivity( intent ); + } } - } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameFrag.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameFrag.java new file mode 100644 index 000000000..c3742be19 --- /dev/null +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameFrag.java @@ -0,0 +1,31 @@ +/* -*- compile-command: "find-and-ant.sh debug install"; -*- */ +/* + * Copyright 2014 by Eric House (xwords@eehouse.org). All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package org.eehouse.android.xw4; + +import android.os.Bundle; + +public class NewGameFrag extends XWFragment implements Delegator { + + @Override + public void onCreate( Bundle sis ) + { + super.onCreate( new NewGameDelegate( this, sis ), sis ); + } +} diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWFragment.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWFragment.java index 74997bb48..bda685884 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWFragment.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWFragment.java @@ -36,13 +36,6 @@ import org.eehouse.android.xw4.loc.LocUtils; public class XWFragment extends Fragment { private DelegateBase m_dlgt; - private int m_layoutID = -1; - - protected void onCreate( DelegateBase dlgt, Bundle sis, int layoutID ) - { - onCreate( dlgt, sis ); - m_layoutID = layoutID; - } public void onCreate( DelegateBase dlgt, Bundle sis ) { @@ -55,13 +48,7 @@ public class XWFragment extends Fragment { Bundle savedInstanceState ) { DbgUtils.logf( "%s.onCreateView() called", this.getClass().getName() ); - View view = null; - if ( 0 < m_layoutID ) { - view = inflater.inflate( m_layoutID, container, false ); - m_dlgt.setContentView( view ); - } - DbgUtils.logf( "%s.onCreateView() => %H", this.getClass().getName(), view ); - return view; + return m_dlgt.inflateView( inflater, container ); } @Override