diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java index a59f143fb..fbaf22e46 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java @@ -210,7 +210,7 @@ public class DelegateBase implements DlgClickNotify, protected void setResult( int result, Intent intent ) { - if ( m_activity instanceof FragActivity ) { + if ( m_activity instanceof MainActivity ) { Assert.fail(); } else { m_activity.setResult( result, intent ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java index cf798eca3..5812b09fa 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Delegator.java @@ -30,7 +30,8 @@ public interface Delegator { void finish(); boolean inDPMode(); void addFragment( XWFragment fragment, Bundle extras ); - + void addFragmentForResult( XWFragment fragment, Bundle extras, + RequestCode requestCode ); // For activities with lists void setListAdapter( ListAdapter adapter ); ListAdapter getListAdapter(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java index 6565bc9c8..f068ac694 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java @@ -278,7 +278,6 @@ public class DictBrowseDelegate extends ListDelegateBase launchLookup( words, m_lang, true ); } - ////////////////////////////////////////////////// // AdapterView.OnItemSelectedListener interface ////////////////////////////////////////////////// @@ -424,10 +423,10 @@ public class DictBrowseDelegate extends ListDelegateBase private static void launch( Delegator delegator, Bundle bundle ) { - Activity activity = delegator.getActivity(); - if ( activity instanceof FragActivity ) { - FragActivity.addFragment( new DictBrowseFrag(), bundle, delegator ); + if ( delegator.inDPMode() ) { + delegator.addFragment( new DictBrowseFrag(), bundle ); } else { + Activity activity = delegator.getActivity(); Intent intent = new Intent( activity, DictBrowseActivity.class ); intent.putExtras( bundle ); activity.startActivity( intent ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java index 2562444fa..67785e28e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java @@ -1209,15 +1209,14 @@ public class GameConfigDelegate extends DelegateBase RequestCode requestCode, long rowID ) { - Activity activity = delegator.getActivity(); Bundle bundle = new Bundle(); bundle.putLong( GameUtils.INTENT_KEY_ROWID, rowID ); bundle.putBoolean( INTENT_FORRESULT_ROWID, true ); - if ( activity instanceof FragActivity ) { - FragActivity.addFragmentForResult( new GameConfigFrag(), bundle, - requestCode, delegator ); + if ( false && delegator.inDPMode() ) { + delegator.addFragmentForResult( new GameConfigFrag(), bundle, requestCode ); } else { + Activity activity = delegator.getActivity(); Intent intent = new Intent( activity, GameConfigActivity.class ); intent.setAction( Intent.ACTION_EDIT ); intent.putExtras( bundle ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index 4194bd1b8..3ca243106 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -1092,10 +1092,10 @@ public class GameUtils { Bundle extras = new Bundle(); extras.putLong( INTENT_KEY_ROWID, rowid ); - Activity activity = delegator.getActivity(); - if ( activity instanceof FragActivity ) { - FragActivity.addFragment( new GameConfigFrag(), extras, delegator ); + if ( delegator.inDPMode() ) { + delegator.addFragment( new GameConfigFrag(), extras ); } else { + Activity activity = delegator.getActivity(); Intent intent = new Intent( activity, GameConfigActivity.class ); intent.setAction( Intent.ACTION_EDIT ); intent.putExtras( extras ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java index 2954a4ffe..82be9fa62 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/MainActivity.java @@ -113,6 +113,14 @@ public class MainActivity extends XWActivity addFragmentImpl( fragment, extras, this ); } + @Override + public void addFragmentForResult( XWFragment fragment, Bundle extras, + RequestCode requestCode ) + { + DbgUtils.logf( "addFragmentForResult(): dropping requestCode" ); + addFragmentImpl( fragment, extras, this ); + } + ////////////////////////////////////////////////////////////////////// // FragmentManager.OnBackStackChangedListener ////////////////////////////////////////////////////////////////////// diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java index 3d98fa528..634674f09 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java @@ -146,4 +146,6 @@ public class PrefsActivity extends PreferenceActivity public boolean inDPMode() { Assert.fail(); return false; } public void addFragment( XWFragment fragment, Bundle extras ) { Assert.fail(); } + public void addFragmentForResult( XWFragment fragment, Bundle extras, + RequestCode code ) { Assert.fail(); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java index 77499b2ae..7b4d03eda 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java @@ -362,9 +362,8 @@ public class StudyListDelegate extends ListDelegateBase bundle.putInt( START_LANG, lang ); } - if ( activity instanceof FragActivity ) { - StudyListFrag frag = new StudyListFrag(); - ((FragActivity)activity).addFragment( frag, bundle, delegator ); + if ( delegator.inDPMode() ) { + delegator.addFragment( new StudyListFrag(), bundle ); } else { Intent intent = new Intent( activity, StudyListActivity.class ); intent.putExtras( bundle ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java index 069479496..e70dc97f1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWActivity.java @@ -231,4 +231,9 @@ public class XWActivity extends FragmentActivity implements Delegator { Assert.fail(); } + public void addFragmentForResult( XWFragment fragment, Bundle extras, + RequestCode request ) + { + Assert.fail(); + } } 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 40c3a069d..8eb10541c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWFragment.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWFragment.java @@ -149,6 +149,14 @@ public class XWFragment extends Fragment main.addFragment( fragment, extras ); } + @Override + public void addFragmentForResult( XWFragment fragment, Bundle extras, + RequestCode code ) + { + MainActivity main = (MainActivity)getActivity(); + main.addFragmentForResult( fragment, extras, code ); + } + // FragActivity.OrientChangeListener public void orientationChanged() {