on ICS+, onPrepareOptionsMenu can get called several times while

adjusting selections, so just bail when they're in an incomplete state.
This commit is contained in:
Eric House 2013-10-21 07:43:31 -07:00
parent b7edbf14a4
commit 7a4d3093a1

View file

@ -617,10 +617,15 @@ public class GamesList extends XWExpandableListActivity
@Override @Override
public boolean onPrepareOptionsMenu( Menu menu ) public boolean onPrepareOptionsMenu( Menu menu )
{ {
boolean show;
int nGamesSelected = m_selectedGames.size(); int nGamesSelected = m_selectedGames.size();
int nGroupsSelected = m_selectedGroups.size(); int nGroupsSelected = m_selectedGroups.size();
if ( 0 < nGamesSelected && 0 < nGroupsSelected ) {
DbgUtils.logf( "onPrepareOptionsMenu: incomplete so bailing" );
show = false;
} else {
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected); boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
Assert.assertTrue( 0 == nGamesSelected || 0 == nGroupsSelected );
boolean visible = XWPrefs.getDebugEnabled( this ); boolean visible = XWPrefs.getDebugEnabled( this );
for ( int id : DEBUGITEMS ) { for ( int id : DEBUGITEMS ) {
@ -676,7 +681,9 @@ public class GamesList extends XWExpandableListActivity
Utils.setItemVisible( menu, R.id.list_item_move, 1 == nGamesSelected ); Utils.setItemVisible( menu, R.id.list_item_move, 1 == nGamesSelected );
Utils.setItemVisible( menu, R.id.list_item_reset, 1 == nGamesSelected ); Utils.setItemVisible( menu, R.id.list_item_reset, 1 == nGamesSelected );
return super.onPrepareOptionsMenu( menu ); show = super.onPrepareOptionsMenu( menu );
}
return show;
} }
public boolean onOptionsItemSelected( MenuItem item ) public boolean onOptionsItemSelected( MenuItem item )