mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
convert remaining delegate launches to work, to varying degrees (but
as they did before), in dual pane mode.
This commit is contained in:
parent
76404258a3
commit
a2b7c71fc1
10 changed files with 37 additions and 16 deletions
|
@ -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 );
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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(); }
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -231,4 +231,9 @@ public class XWActivity extends FragmentActivity implements Delegator {
|
|||
Assert.fail();
|
||||
}
|
||||
|
||||
public void addFragmentForResult( XWFragment fragment, Bundle extras,
|
||||
RequestCode request )
|
||||
{
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue