mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
cleanup menu config code
This commit is contained in:
parent
e197e7499f
commit
8ab202dd27
1 changed files with 20 additions and 22 deletions
|
@ -94,7 +94,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
,CLEAR_SELS
|
,CLEAR_SELS
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final int[] DEBUGITEMS = {
|
private static final int[] DEBUG_ITEMS = {
|
||||||
R.id.games_menu_loaddb,
|
R.id.games_menu_loaddb,
|
||||||
R.id.games_menu_storedb,
|
R.id.games_menu_storedb,
|
||||||
R.id.games_menu_checkupdates,
|
R.id.games_menu_checkupdates,
|
||||||
|
@ -665,24 +665,14 @@ public class GamesList extends XWExpandableListActivity
|
||||||
if ( m_menuPrepared ) {
|
if ( m_menuPrepared ) {
|
||||||
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
|
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
|
||||||
|
|
||||||
boolean visible = XWPrefs.getDebugEnabled( this );
|
boolean showDbg = XWPrefs.getDebugEnabled( this );
|
||||||
for ( int id : DEBUGITEMS ) {
|
showItemsIf( DEBUG_ITEMS, menu, nothingSelected && showDbg );
|
||||||
Utils.setItemVisible( menu, id, nothingSelected && visible );
|
Utils.setItemVisible( menu, R.id.games_menu_loaddb,
|
||||||
}
|
showDbg && !DBUtils.gameDBExists( this ) );
|
||||||
|
|
||||||
if ( visible && !DBUtils.gameDBExists( this ) ) {
|
showItemsIf( NOSEL_ITEMS, menu, nothingSelected );
|
||||||
Utils.setItemVisible( menu, R.id.games_menu_loaddb, false );
|
showItemsIf( ONEGAME_ITEMS, menu, 1 == nGamesSelected );
|
||||||
}
|
showItemsIf( ONEGROUP_ITEMS, menu, 1 == nGroupsSelected );
|
||||||
|
|
||||||
for ( int id : NOSEL_ITEMS ) {
|
|
||||||
Utils.setItemVisible( menu, id, nothingSelected );
|
|
||||||
}
|
|
||||||
for ( int id : ONEGAME_ITEMS ) {
|
|
||||||
Utils.setItemVisible( menu, id, 1 == nGamesSelected );
|
|
||||||
}
|
|
||||||
for ( int id : ONEGROUP_ITEMS ) {
|
|
||||||
Utils.setItemVisible( menu, id, 1 == nGroupsSelected );
|
|
||||||
}
|
|
||||||
|
|
||||||
int selGroupPos = -1;
|
int selGroupPos = -1;
|
||||||
if ( 1 == nGroupsSelected ) {
|
if ( 1 == nGroupsSelected ) {
|
||||||
|
@ -701,9 +691,10 @@ public class GamesList extends XWExpandableListActivity
|
||||||
|
|
||||||
// Move up/down enabled for groups if not the top-most or bottommost
|
// Move up/down enabled for groups if not the top-most or bottommost
|
||||||
// selected
|
// selected
|
||||||
boolean enable = 0 < selGroupPos;
|
Utils.setItemVisible( menu, R.id.games_group_moveup,
|
||||||
Utils.setItemVisible( menu, R.id.games_group_moveup, enable );
|
0 < selGroupPos );
|
||||||
enable = 0 <= selGroupPos && selGroupPos + 1 < m_adapter.getGroupCount();
|
boolean enable = 0 <= selGroupPos
|
||||||
|
&& (selGroupPos + 1) < m_adapter.getGroupCount();
|
||||||
Utils.setItemVisible( menu, R.id.games_group_movedown, enable );
|
Utils.setItemVisible( menu, R.id.games_group_movedown, enable );
|
||||||
|
|
||||||
// New game available when nothing selected or one group
|
// New game available when nothing selected or one group
|
||||||
|
@ -716,7 +707,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
Utils.setItemVisible( menu, R.id.games_group_delete,
|
Utils.setItemVisible( menu, R.id.games_group_delete,
|
||||||
0 < nGroupsSelected );
|
0 < nGroupsSelected );
|
||||||
|
|
||||||
// multiple games can be regrouped/reset. (Later....)
|
// multiple games can be regrouped/reset.
|
||||||
Utils.setItemVisible( menu, R.id.games_game_move,
|
Utils.setItemVisible( menu, R.id.games_game_move,
|
||||||
(1 < m_adapter.getGroupCount()
|
(1 < m_adapter.getGroupCount()
|
||||||
&& 0 < nGamesSelected) );
|
&& 0 < nGamesSelected) );
|
||||||
|
@ -1323,6 +1314,13 @@ public class GamesList extends XWExpandableListActivity
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showItemsIf( int[] items, Menu menu, boolean select )
|
||||||
|
{
|
||||||
|
for ( int item : items ) {
|
||||||
|
Utils.setItemVisible( menu, item, select );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void onGameDictDownload( Context context, Intent intent )
|
public static void onGameDictDownload( Context context, Intent intent )
|
||||||
{
|
{
|
||||||
intent.setClass( context, GamesList.class );
|
intent.setClass( context, GamesList.class );
|
||||||
|
|
Loading…
Add table
Reference in a new issue