mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
fix so when left pane launches a fragment it replaces the right
Required passing parent into constructors so it's available for matching against the left pane later.
This commit is contained in:
parent
2b58072524
commit
5dee7080a0
15 changed files with 43 additions and 27 deletions
|
@ -24,6 +24,8 @@ import android.os.Bundle;
|
||||||
|
|
||||||
public class BoardFrag extends XWFragment {
|
public class BoardFrag extends XWFragment {
|
||||||
|
|
||||||
|
public BoardFrag( Delegator parent ) { super( parent ); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle sis )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
|
|
|
@ -265,7 +265,7 @@ public class ChatDelegate extends DelegateBase {
|
||||||
bundle.putBooleanArray( INTENT_KEY_LOCS, locs );
|
bundle.putBooleanArray( INTENT_KEY_LOCS, locs );
|
||||||
|
|
||||||
if ( delegator.inDPMode() ) {
|
if ( delegator.inDPMode() ) {
|
||||||
delegator.addFragment( new ChatFrag(), bundle );
|
delegator.addFragment( new ChatFrag( delegator ), bundle );
|
||||||
} else {
|
} else {
|
||||||
Activity activity = delegator.getActivity();
|
Activity activity = delegator.getActivity();
|
||||||
Intent intent = new Intent( activity, ChatActivity.class );
|
Intent intent = new Intent( activity, ChatActivity.class );
|
||||||
|
|
|
@ -23,6 +23,8 @@ import android.os.Bundle;
|
||||||
|
|
||||||
public class ChatFrag extends XWFragment {
|
public class ChatFrag extends XWFragment {
|
||||||
|
|
||||||
|
public ChatFrag( Delegator parent ) { super( parent ); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle sis )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
|
|
|
@ -424,7 +424,7 @@ public class DictBrowseDelegate extends ListDelegateBase
|
||||||
private static void launch( Delegator delegator, Bundle bundle )
|
private static void launch( Delegator delegator, Bundle bundle )
|
||||||
{
|
{
|
||||||
if ( delegator.inDPMode() ) {
|
if ( delegator.inDPMode() ) {
|
||||||
delegator.addFragment( new DictBrowseFrag(), bundle );
|
delegator.addFragment( new DictBrowseFrag( delegator ), bundle );
|
||||||
} else {
|
} else {
|
||||||
Activity activity = delegator.getActivity();
|
Activity activity = delegator.getActivity();
|
||||||
Intent intent = new Intent( activity, DictBrowseActivity.class );
|
Intent intent = new Intent( activity, DictBrowseActivity.class );
|
||||||
|
|
|
@ -23,6 +23,8 @@ import android.os.Bundle;
|
||||||
|
|
||||||
public class DictBrowseFrag extends XWFragment {
|
public class DictBrowseFrag extends XWFragment {
|
||||||
|
|
||||||
|
public DictBrowseFrag( Delegator parent ) { super( parent ); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle sis )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1450,7 +1450,7 @@ public class DictsDelegate extends ListDelegateBase
|
||||||
public static void start( Delegator delegator )
|
public static void start( Delegator delegator )
|
||||||
{
|
{
|
||||||
if ( delegator.inDPMode() ) {
|
if ( delegator.inDPMode() ) {
|
||||||
delegator.addFragment( new DictsFrag(), null );
|
delegator.addFragment( new DictsFrag( delegator ), null );
|
||||||
} else {
|
} else {
|
||||||
Activity activity = delegator.getActivity();
|
Activity activity = delegator.getActivity();
|
||||||
Intent intent = new Intent( activity, DictsActivity.class );
|
Intent intent = new Intent( activity, DictsActivity.class );
|
||||||
|
|
|
@ -23,6 +23,8 @@ import android.os.Bundle;
|
||||||
|
|
||||||
public class DictsFrag extends XWFragment {
|
public class DictsFrag extends XWFragment {
|
||||||
|
|
||||||
|
public DictsFrag( Delegator parent ) { super( parent ); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle sis )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1234,7 +1234,8 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
bundle.putBoolean( INTENT_FORRESULT_ROWID, true );
|
bundle.putBoolean( INTENT_FORRESULT_ROWID, true );
|
||||||
|
|
||||||
if ( delegator.inDPMode() ) {
|
if ( delegator.inDPMode() ) {
|
||||||
delegator.addFragmentForResult( new GameConfigFrag(), bundle, requestCode );
|
delegator.addFragmentForResult( new GameConfigFrag( delegator ),
|
||||||
|
bundle, requestCode );
|
||||||
} else {
|
} else {
|
||||||
Activity activity = delegator.getActivity();
|
Activity activity = delegator.getActivity();
|
||||||
Intent intent = new Intent( activity, GameConfigActivity.class );
|
Intent intent = new Intent( activity, GameConfigActivity.class );
|
||||||
|
|
|
@ -23,6 +23,8 @@ import android.os.Bundle;
|
||||||
|
|
||||||
public class GameConfigFrag extends XWFragment {
|
public class GameConfigFrag extends XWFragment {
|
||||||
|
|
||||||
|
public GameConfigFrag( Delegator parent ) { super( parent ); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle sis )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
|
|
|
@ -853,7 +853,7 @@ public class GameUtils {
|
||||||
{
|
{
|
||||||
Bundle extras = makeLaunchExtras( rowid, invited );
|
Bundle extras = makeLaunchExtras( rowid, invited );
|
||||||
if ( delegator.inDPMode() ) {
|
if ( delegator.inDPMode() ) {
|
||||||
delegator.addFragment( new BoardFrag(), extras );
|
delegator.addFragment( new BoardFrag( delegator ), extras );
|
||||||
} else {
|
} else {
|
||||||
Activity activity = delegator.getActivity();
|
Activity activity = delegator.getActivity();
|
||||||
Intent intent = new Intent( activity, BoardActivity.class );
|
Intent intent = new Intent( activity, BoardActivity.class );
|
||||||
|
@ -1093,7 +1093,7 @@ public class GameUtils {
|
||||||
extras.putLong( INTENT_KEY_ROWID, rowid );
|
extras.putLong( INTENT_KEY_ROWID, rowid );
|
||||||
|
|
||||||
if ( delegator.inDPMode() ) {
|
if ( delegator.inDPMode() ) {
|
||||||
delegator.addFragment( new GameConfigFrag(), extras );
|
delegator.addFragment( new GameConfigFrag( delegator ), extras );
|
||||||
} else {
|
} else {
|
||||||
Activity activity = delegator.getActivity();
|
Activity activity = delegator.getActivity();
|
||||||
Intent intent = new Intent( activity, GameConfigActivity.class );
|
Intent intent = new Intent( activity, GameConfigActivity.class );
|
||||||
|
|
|
@ -24,6 +24,8 @@ import android.os.Bundle;
|
||||||
|
|
||||||
public class GamesListFrag extends XWFragment {
|
public class GamesListFrag extends XWFragment {
|
||||||
|
|
||||||
|
public GamesListFrag( Delegator parent ) { super( parent ); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle sis )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,7 +87,8 @@ public class MainActivity extends XWActivity
|
||||||
if ( savedInstanceState == null ) {
|
if ( savedInstanceState == null ) {
|
||||||
// In case this activity was started with special instructions from an Intent,
|
// In case this activity was started with special instructions from an Intent,
|
||||||
// pass the Intent's extras to the fragment as arguments
|
// pass the Intent's extras to the fragment as arguments
|
||||||
addFragmentImpl( new GamesListFrag(), getIntent().getExtras(), null );
|
addFragmentImpl( new GamesListFrag(null),
|
||||||
|
getIntent().getExtras(), null );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // onCreate
|
} // onCreate
|
||||||
|
@ -217,7 +218,7 @@ public class MainActivity extends XWActivity
|
||||||
@Override
|
@Override
|
||||||
public void addFragment( XWFragment fragment, Bundle extras )
|
public void addFragment( XWFragment fragment, Bundle extras )
|
||||||
{
|
{
|
||||||
addFragmentImpl( fragment, extras, this );
|
addFragmentImpl( fragment, extras, fragment.getParent() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -230,7 +231,7 @@ public class MainActivity extends XWActivity
|
||||||
= new WeakReference<DelegateBase>(fragment.getDelegate());
|
= new WeakReference<DelegateBase>(fragment.getDelegate());
|
||||||
m_pendingCodes.put( requestCode, ref );
|
m_pendingCodes.put( requestCode, ref );
|
||||||
|
|
||||||
addFragmentImpl( fragment, extras, this );
|
addFragmentImpl( fragment, extras, fragment.getParent() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setFragmentResult( DelegateBase delegate, int resultCode,
|
protected void setFragmentResult( DelegateBase delegate, int resultCode,
|
||||||
|
@ -344,9 +345,9 @@ public class MainActivity extends XWActivity
|
||||||
addFragmentImpl( fragment, parent );
|
addFragmentImpl( fragment, parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFragmentImpl( Fragment fragment, Delegator delegator )
|
private void addFragmentImpl( Fragment fragment, Delegator parent )
|
||||||
{
|
{
|
||||||
String newName = fragment.getClass().getName();
|
String newName = fragment.getClass().getSimpleName();
|
||||||
boolean replace = false;
|
boolean replace = false;
|
||||||
FragmentManager fm = getSupportFragmentManager();
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
int fragCount = fm.getBackStackEntryCount();
|
int fragCount = fm.getBackStackEntryCount();
|
||||||
|
@ -357,23 +358,18 @@ public class MainActivity extends XWActivity
|
||||||
// Replace IF we're adding something of the same class at right OR if
|
// Replace IF we're adding something of the same class at right OR if
|
||||||
// we're adding something with the existing left pane as its parent
|
// we're adding something with the existing left pane as its parent
|
||||||
// (delegator)
|
// (delegator)
|
||||||
if ( 0 < fragCount ) {
|
if ( 1 < fragCount ) {
|
||||||
FragmentManager.BackStackEntry entry = fm.getBackStackEntryAt( fragCount - 1 );
|
Assert.assertTrue( MAX_PANES_LANDSCAPE == 2 ); // otherwise FIXME
|
||||||
|
FragmentManager.BackStackEntry entry
|
||||||
|
= fm.getBackStackEntryAt( fragCount - 2 );
|
||||||
String curName = entry.getName();
|
String curName = entry.getName();
|
||||||
DbgUtils.logf( "name of last entry: %s", curName );
|
String delName = parent.getClass().getSimpleName();
|
||||||
replace = curName.equals( newName );
|
// DbgUtils.logf( "comparing %s, %s", curName, delName );
|
||||||
|
replace = curName.equals( delName );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !replace && 1 < fragCount ) {
|
if ( replace ) {
|
||||||
entry = fm.getBackStackEntryAt( fragCount - 2 );
|
fm.popBackStack();
|
||||||
curName = entry.getName();
|
|
||||||
String delName = delegator.getClass().getName();
|
|
||||||
DbgUtils.logf( "comparing %s, %s", curName, delName );
|
|
||||||
replace = curName.equals( delName );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( replace ) {
|
|
||||||
fm.popBackStack();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace doesn't seem to work with generated IDs, so we'll create a
|
// Replace doesn't seem to work with generated IDs, so we'll create a
|
||||||
|
|
|
@ -363,7 +363,7 @@ public class StudyListDelegate extends ListDelegateBase
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( delegator.inDPMode() ) {
|
if ( delegator.inDPMode() ) {
|
||||||
delegator.addFragment( new StudyListFrag(), bundle );
|
delegator.addFragment( new StudyListFrag( delegator ), bundle );
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent( activity, StudyListActivity.class );
|
Intent intent = new Intent( activity, StudyListActivity.class );
|
||||||
intent.putExtras( bundle );
|
intent.putExtras( bundle );
|
||||||
|
|
|
@ -24,6 +24,8 @@ import android.os.Bundle;
|
||||||
|
|
||||||
public class StudyListFrag extends XWFragment {
|
public class StudyListFrag extends XWFragment {
|
||||||
|
|
||||||
|
public StudyListFrag( Delegator parent ) { super( parent ); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate( Bundle sis )
|
public void onCreate( Bundle sis )
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,8 +37,13 @@ import junit.framework.Assert;
|
||||||
public class XWFragment extends Fragment implements Delegator {
|
public class XWFragment extends Fragment implements Delegator {
|
||||||
|
|
||||||
private DelegateBase m_dlgt;
|
private DelegateBase m_dlgt;
|
||||||
|
private Delegator m_parent;
|
||||||
private boolean m_hasOptionsMenu = false;
|
private boolean m_hasOptionsMenu = false;
|
||||||
|
|
||||||
|
public XWFragment( Delegator parent ) { m_parent = parent; }
|
||||||
|
|
||||||
|
public Delegator getParent() { return m_parent; }
|
||||||
|
|
||||||
protected void onCreate( DelegateBase dlgt, Bundle sis, boolean hasOptionsMenu )
|
protected void onCreate( DelegateBase dlgt, Bundle sis, boolean hasOptionsMenu )
|
||||||
{
|
{
|
||||||
m_hasOptionsMenu = hasOptionsMenu;
|
m_hasOptionsMenu = hasOptionsMenu;
|
||||||
|
|
Loading…
Reference in a new issue