When there's a selection change title bar text to show count

This commit is contained in:
Eric House 2013-10-23 07:15:09 -07:00
parent 2c63be81e8
commit ab3209ca70
2 changed files with 28 additions and 0 deletions

View file

@ -2166,4 +2166,7 @@
can instead tap the icons at the left to select or deselect games, can instead tap the icons at the left to select or deselect games,
then act on selected games, e.g. to delete them, using the menu or then act on selected games, e.g. to delete them, using the menu or
\"Actionbar.\"</string> \"Actionbar.\"</string>
<string name="sel_gamesf">Games: %d"</string>
<string name="sel_groupsf">Groups: %d"</string>
</resources> </resources>

View file

@ -133,6 +133,7 @@ public class GamesList extends XWExpandableListActivity
private boolean m_menuPrepared; private boolean m_menuPrepared;
private HashSet<Long> m_selGames; private HashSet<Long> m_selGames;
private HashSet<Long> m_selGroupIDs; private HashSet<Long> m_selGroupIDs;
private CharSequence m_origTitle;
@Override @Override
protected Dialog onCreateDialog( int id ) protected Dialog onCreateDialog( int id )
@ -389,6 +390,8 @@ public class GamesList extends XWExpandableListActivity
tryStartsFromIntent( getIntent() ); tryStartsFromIntent( getIntent() );
askDefaultNameIf(); askDefaultNameIf();
m_origTitle = getTitle();
} // onCreate } // onCreate
@Override @Override
@ -516,6 +519,7 @@ public class GamesList extends XWExpandableListActivity
} }
} }
Utils.invalidateOptionsMenuIf( this ); Utils.invalidateOptionsMenuIf( this );
setTitleBar();
} }
public boolean getSelected( long rowid ) public boolean getSelected( long rowid )
@ -868,6 +872,26 @@ public class GamesList extends XWExpandableListActivity
} ); } );
} }
private void setTitleBar()
{
int fmt = 0;
int nSels = m_selGames.size();
if ( 0 < nSels ) {
fmt = R.string.sel_gamesf;
} else {
nSels = m_selGroupIDs.size();
if ( 0 < nSels ) {
fmt = R.string.sel_groupsf;
}
}
if ( 0 == fmt ) {
setTitle( m_origTitle );
} else {
setTitle( getString( fmt, nSels ) );
}
}
private boolean checkWarnNoDict( NetLaunchInfo nli ) private boolean checkWarnNoDict( NetLaunchInfo nli )
{ {
// check that we have the dict required // check that we have the dict required
@ -1125,6 +1149,7 @@ public class GamesList extends XWExpandableListActivity
} }
if ( inval ) { if ( inval ) {
Utils.invalidateOptionsMenuIf( this ); Utils.invalidateOptionsMenuIf( this );
setTitleBar();
} }
} }