From 1bb0c49c711b623b71febf2aec24bd133aebc7f7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 21 Oct 2013 20:44:47 -0700 Subject: [PATCH] assert that we don't use an unprepared menu. --- .../src/org/eehouse/android/xw4/GamesList.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 fb557bd40..41ef46f3a 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -129,6 +129,7 @@ public class GamesList extends XWExpandableListActivity private NetLaunchInfo m_netLaunchInfo; private GameNamer m_namer; private boolean m_gameLaunched = false; + private boolean m_menuPrepared; private HashSet m_selectedGames; private HashSet m_selectedGroups; @@ -617,14 +618,10 @@ public class GamesList extends XWExpandableListActivity @Override public boolean onPrepareOptionsMenu( Menu menu ) { - boolean show; - int nGamesSelected = m_selectedGames.size(); int nGroupsSelected = m_selectedGroups.size(); - if ( 0 < nGamesSelected && 0 < nGroupsSelected ) { - DbgUtils.logf( "onPrepareOptionsMenu: incomplete so bailing" ); - show = false; - } else { + m_menuPrepared = 0 == nGamesSelected || 0 == nGroupsSelected; + if ( m_menuPrepared ) { boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected); boolean visible = XWPrefs.getDebugEnabled( this ); @@ -681,13 +678,17 @@ public class GamesList extends XWExpandableListActivity Utils.setItemVisible( menu, R.id.list_item_move, 1 == nGamesSelected ); Utils.setItemVisible( menu, R.id.list_item_reset, 1 == nGamesSelected ); - show = super.onPrepareOptionsMenu( menu ); + m_menuPrepared = super.onPrepareOptionsMenu( menu ); + } else { + DbgUtils.logf( "onPrepareOptionsMenu: incomplete so bailing" ); } - return show; + return m_menuPrepared; } public boolean onOptionsItemSelected( MenuItem item ) { + Assert.assertTrue( m_menuPrepared ); + boolean handled = true; int groupPos = getSelGroupPos(); long groupID = -1;