convert remaining delegate launches to work, to varying degrees (but

as they did before), in dual pane mode.
This commit is contained in:
Eric House 2016-07-10 15:01:19 -07:00
parent 76404258a3
commit a2b7c71fc1
10 changed files with 37 additions and 16 deletions

View file

@ -210,7 +210,7 @@ public class DelegateBase implements DlgClickNotify,
protected void setResult( int result, Intent intent ) protected void setResult( int result, Intent intent )
{ {
if ( m_activity instanceof FragActivity ) { if ( m_activity instanceof MainActivity ) {
Assert.fail(); Assert.fail();
} else { } else {
m_activity.setResult( result, intent ); m_activity.setResult( result, intent );

View file

@ -30,7 +30,8 @@ public interface Delegator {
void finish(); void finish();
boolean inDPMode(); boolean inDPMode();
void addFragment( XWFragment fragment, Bundle extras ); void addFragment( XWFragment fragment, Bundle extras );
void addFragmentForResult( XWFragment fragment, Bundle extras,
RequestCode requestCode );
// For activities with lists // For activities with lists
void setListAdapter( ListAdapter adapter ); void setListAdapter( ListAdapter adapter );
ListAdapter getListAdapter(); ListAdapter getListAdapter();

View file

@ -278,7 +278,6 @@ public class DictBrowseDelegate extends ListDelegateBase
launchLookup( words, m_lang, true ); launchLookup( words, m_lang, true );
} }
////////////////////////////////////////////////// //////////////////////////////////////////////////
// AdapterView.OnItemSelectedListener interface // AdapterView.OnItemSelectedListener interface
////////////////////////////////////////////////// //////////////////////////////////////////////////
@ -424,10 +423,10 @@ public class DictBrowseDelegate extends ListDelegateBase
private static void launch( Delegator delegator, Bundle bundle ) private static void launch( Delegator delegator, Bundle bundle )
{ {
Activity activity = delegator.getActivity(); if ( delegator.inDPMode() ) {
if ( activity instanceof FragActivity ) { delegator.addFragment( new DictBrowseFrag(), bundle );
FragActivity.addFragment( new DictBrowseFrag(), bundle, delegator );
} else { } else {
Activity activity = delegator.getActivity();
Intent intent = new Intent( activity, DictBrowseActivity.class ); Intent intent = new Intent( activity, DictBrowseActivity.class );
intent.putExtras( bundle ); intent.putExtras( bundle );
activity.startActivity( intent ); activity.startActivity( intent );

View file

@ -1209,15 +1209,14 @@ public class GameConfigDelegate extends DelegateBase
RequestCode requestCode, RequestCode requestCode,
long rowID ) long rowID )
{ {
Activity activity = delegator.getActivity();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putLong( GameUtils.INTENT_KEY_ROWID, rowID ); bundle.putLong( GameUtils.INTENT_KEY_ROWID, rowID );
bundle.putBoolean( INTENT_FORRESULT_ROWID, true ); bundle.putBoolean( INTENT_FORRESULT_ROWID, true );
if ( activity instanceof FragActivity ) { if ( false && delegator.inDPMode() ) {
FragActivity.addFragmentForResult( new GameConfigFrag(), bundle, delegator.addFragmentForResult( new GameConfigFrag(), bundle, requestCode );
requestCode, delegator );
} else { } else {
Activity activity = delegator.getActivity();
Intent intent = new Intent( activity, GameConfigActivity.class ); Intent intent = new Intent( activity, GameConfigActivity.class );
intent.setAction( Intent.ACTION_EDIT ); intent.setAction( Intent.ACTION_EDIT );
intent.putExtras( bundle ); intent.putExtras( bundle );

View file

@ -1092,10 +1092,10 @@ public class GameUtils {
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putLong( INTENT_KEY_ROWID, rowid ); extras.putLong( INTENT_KEY_ROWID, rowid );
Activity activity = delegator.getActivity(); if ( delegator.inDPMode() ) {
if ( activity instanceof FragActivity ) { delegator.addFragment( new GameConfigFrag(), extras );
FragActivity.addFragment( new GameConfigFrag(), extras, delegator );
} else { } else {
Activity activity = delegator.getActivity();
Intent intent = new Intent( activity, GameConfigActivity.class ); Intent intent = new Intent( activity, GameConfigActivity.class );
intent.setAction( Intent.ACTION_EDIT ); intent.setAction( Intent.ACTION_EDIT );
intent.putExtras( extras ); intent.putExtras( extras );

View file

@ -113,6 +113,14 @@ public class MainActivity extends XWActivity
addFragmentImpl( fragment, extras, this ); 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 // FragmentManager.OnBackStackChangedListener
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////

View file

@ -146,4 +146,6 @@ public class PrefsActivity extends PreferenceActivity
public boolean inDPMode() { Assert.fail(); return false; } public boolean inDPMode() { Assert.fail(); return false; }
public void addFragment( XWFragment fragment, Bundle extras ) { Assert.fail(); } public void addFragment( XWFragment fragment, Bundle extras ) { Assert.fail(); }
public void addFragmentForResult( XWFragment fragment, Bundle extras,
RequestCode code ) { Assert.fail(); }
} }

View file

@ -362,9 +362,8 @@ public class StudyListDelegate extends ListDelegateBase
bundle.putInt( START_LANG, lang ); bundle.putInt( START_LANG, lang );
} }
if ( activity instanceof FragActivity ) { if ( delegator.inDPMode() ) {
StudyListFrag frag = new StudyListFrag(); delegator.addFragment( new StudyListFrag(), bundle );
((FragActivity)activity).addFragment( frag, bundle, delegator );
} else { } else {
Intent intent = new Intent( activity, StudyListActivity.class ); Intent intent = new Intent( activity, StudyListActivity.class );
intent.putExtras( bundle ); intent.putExtras( bundle );

View file

@ -231,4 +231,9 @@ public class XWActivity extends FragmentActivity implements Delegator {
Assert.fail(); Assert.fail();
} }
public void addFragmentForResult( XWFragment fragment, Bundle extras,
RequestCode request )
{
Assert.fail();
}
} }

View file

@ -149,6 +149,14 @@ public class XWFragment extends Fragment
main.addFragment( fragment, extras ); 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 // FragActivity.OrientChangeListener
public void orientationChanged() public void orientationChanged()
{ {