From ec2fb210be8af2f342543dc2bcfd59d9187a04e1 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 21 Nov 2013 08:00:59 -0800 Subject: [PATCH] on return from opening a game, select that game after clearing the selection --- .../eehouse/android/xw4/GameListAdapter.java | 2 +- .../org/eehouse/android/xw4/GamesList.java | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java index 4b675d619..9e5d03787 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -415,7 +415,7 @@ public class GameListAdapter implements ExpandableListAdapter { } } - private GameListItem getGameItemFor( long rowid ) + protected GameListItem getGameItemFor( long rowid ) { long[] rowids = { rowid }; GameListItem[] items = new GameListItem[1]; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index be0c62ebe..95055778e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -131,7 +131,7 @@ public class GamesList extends XWExpandableListActivity private String m_nameField; private NetLaunchInfo m_netLaunchInfo; private GameNamer m_namer; - private boolean m_gameLaunched = false; + private long m_launchedGame = 0; private boolean m_menuPrepared; private HashSet m_selGames; private HashSet m_selGroupIDs; @@ -409,7 +409,7 @@ public class GamesList extends XWExpandableListActivity protected void onNewIntent( Intent intent ) { super.onNewIntent( intent ); - m_gameLaunched = false; + m_launchedGame = 0; Assert.assertNotNull( intent ); invalRelayIDs( intent.getStringArrayExtra( RELAYIDS_EXTRA ) ); invalRowID( intent.getLongExtra( ROWID_EXTRA, -1 ) ); @@ -465,7 +465,11 @@ public class GamesList extends XWExpandableListActivity super.onWindowFocusChanged( hasFocus ); if ( hasFocus ) { updateField(); - m_gameLaunched = false; + + if ( 0 != m_launchedGame ) { + selectJustLaunched(); + m_launchedGame = 0; + } } } @@ -502,7 +506,7 @@ public class GamesList extends XWExpandableListActivity // dialog in case it was dismissed. That way it to check for // an empty room name. if ( clicked instanceof GameListItem ) { - if ( !m_gameLaunched ) { + if ( 0 == m_launchedGame ) { long rowid = ((GameListItem)clicked).getRowID(); showNotAgainDlgThen( R.string.not_again_newselect, R.string.key_notagain_newselect, @@ -1240,8 +1244,8 @@ public class GamesList extends XWExpandableListActivity private void launchGame( long rowid, boolean invited ) { - if ( !m_gameLaunched ) { - m_gameLaunched = true; + if ( 0 == m_launchedGame ) { + m_launchedGame = rowid; GameUtils.launchGame( this, rowid, invited ); } } @@ -1331,6 +1335,12 @@ public class GamesList extends XWExpandableListActivity } } + private void selectJustLaunched() + { + clearSelections(); + m_adapter.getGameItemFor( m_launchedGame ).setSelected( true ); + } + public static void onGameDictDownload( Context context, Intent intent ) { intent.setClass( context, GamesList.class );