mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-01 19:57:11 +01:00
fix move-group AOOB and menu enablement for context case
This commit is contained in:
parent
0e58e24c3d
commit
f55796f845
1 changed files with 31 additions and 18 deletions
|
@ -352,16 +352,20 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
void moveGroup( long groupID, boolean moveUp )
|
void moveGroup( long groupID, boolean moveUp )
|
||||||
{
|
{
|
||||||
int src = getGroupPosition( groupID );
|
try {
|
||||||
int dest = src + (moveUp ? -1 : 1);
|
int src = getGroupPosition( groupID );
|
||||||
|
int dest = src + (moveUp ? -1 : 1);
|
||||||
|
|
||||||
long[] positions = getGroupPositions();
|
long[] positions = getGroupPositions();
|
||||||
long tmp = positions[src];
|
long tmp = positions[src];
|
||||||
positions[src] = positions[dest];
|
positions[src] = positions[dest];
|
||||||
positions[dest] = tmp;
|
positions[dest] = tmp;
|
||||||
storeGroupPositions( positions );
|
storeGroupPositions( positions );
|
||||||
|
|
||||||
swapGroups( src, dest );
|
swapGroups( src, dest );
|
||||||
|
} catch ( ArrayIndexOutOfBoundsException ioob ) {
|
||||||
|
Log.ex( TAG, ioob );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean setField( String newField )
|
boolean setField( String newField )
|
||||||
|
@ -1566,10 +1570,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
// 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
|
||||||
enable = 1 == nGroupsSelected;
|
enable = 1 == nGroupsSelected;
|
||||||
Utils.setItemVisible( menu, R.id.games_group_moveup,
|
enableGroupUpDown( menu, selGroupPos, enable );
|
||||||
enable && 0 < selGroupPos );
|
|
||||||
Utils.setItemVisible( menu, R.id.games_group_movedown, enable
|
|
||||||
&& (selGroupPos + 1) < groupCount );
|
|
||||||
|
|
||||||
// New game available when nothing selected or one group
|
// New game available when nothing selected or one group
|
||||||
Utils.setItemVisible( menu, R.id.games_menu_newgame_solo,
|
Utils.setItemVisible( menu, R.id.games_menu_newgame_solo,
|
||||||
|
@ -1740,22 +1741,24 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
boolean selected = false;
|
boolean selected = false;
|
||||||
GameListItem item = null;
|
GameListItem gameItem = null;
|
||||||
|
int selGroupPos = -1;
|
||||||
AdapterView.AdapterContextMenuInfo info
|
AdapterView.AdapterContextMenuInfo info
|
||||||
= (AdapterView.AdapterContextMenuInfo)menuInfo;
|
= (AdapterView.AdapterContextMenuInfo)menuInfo;
|
||||||
View targetView = info.targetView;
|
View targetView = info.targetView;
|
||||||
Log.d( TAG, "onCreateContextMenu(t=%s)",
|
Log.d( TAG, "onCreateContextMenu(t=%s)",
|
||||||
targetView.getClass().getSimpleName() );
|
targetView.getClass().getSimpleName() );
|
||||||
if ( targetView instanceof GameListItem ) {
|
if ( targetView instanceof GameListItem ) {
|
||||||
item = (GameListItem)targetView;
|
gameItem = (GameListItem)targetView;
|
||||||
id = R.menu.games_list_game_menu;
|
id = R.menu.games_list_game_menu;
|
||||||
|
|
||||||
selected = m_mySIS.selGames.contains( item.getRowID() );
|
selected = m_mySIS.selGames.contains( gameItem.getRowID() );
|
||||||
} else if ( targetView instanceof GameListGroup ) {
|
} else if ( targetView instanceof GameListGroup ) {
|
||||||
id = R.menu.games_list_group_menu;
|
id = R.menu.games_list_group_menu;
|
||||||
|
|
||||||
long groupID = ((GameListGroup)targetView).getGroupID();
|
long groupID = ((GameListGroup)targetView).getGroupID();
|
||||||
selected = m_mySIS.selGroupIDs.contains( groupID );
|
selected = m_mySIS.selGroupIDs.contains( groupID );
|
||||||
|
selGroupPos = m_adapter.getGroupPosition( groupID );
|
||||||
} else {
|
} else {
|
||||||
Assert.failDbg();
|
Assert.failDbg();
|
||||||
}
|
}
|
||||||
|
@ -1767,13 +1770,13 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
? R.id.games_game_select : R.id.games_game_deselect;
|
? R.id.games_game_select : R.id.games_game_deselect;
|
||||||
Utils.setItemVisible( menu, hideId, false );
|
Utils.setItemVisible( menu, hideId, false );
|
||||||
|
|
||||||
if ( null != item ) {
|
if ( null != gameItem ) {
|
||||||
long rowID = item.getRowID();
|
long rowID = gameItem.getRowID();
|
||||||
enable = BoardDelegate.rematchSupported( m_activity, rowID );
|
enable = BoardDelegate.rematchSupported( m_activity, rowID );
|
||||||
Utils.setItemVisible( menu, R.id.games_game_rematch, enable );
|
Utils.setItemVisible( menu, R.id.games_game_rematch, enable );
|
||||||
|
|
||||||
// Deal with possibility summary's temporarily null....
|
// Deal with possibility summary's temporarily null....
|
||||||
GameSummary summary = item.getSummary();
|
GameSummary summary = gameItem.getSummary();
|
||||||
enable = false;
|
enable = false;
|
||||||
boolean isMultiGame = false;
|
boolean isMultiGame = false;
|
||||||
if ( null != summary ) {
|
if ( null != summary ) {
|
||||||
|
@ -1790,6 +1793,8 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
enable = !m_launchedGames.contains( rowID );
|
enable = !m_launchedGames.contains( rowID );
|
||||||
Utils.setItemVisible( menu, R.id.games_game_delete, enable );
|
Utils.setItemVisible( menu, R.id.games_game_delete, enable );
|
||||||
Utils.setItemVisible( menu, R.id.games_game_reset, enable );
|
Utils.setItemVisible( menu, R.id.games_game_reset, enable );
|
||||||
|
} else {
|
||||||
|
enableGroupUpDown( menu, selGroupPos, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // onCreateContextMenu
|
} // onCreateContextMenu
|
||||||
|
@ -1865,6 +1870,14 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void enableGroupUpDown( Menu menu, int selGroupPos, final boolean enable )
|
||||||
|
{
|
||||||
|
Utils.setItemVisible( menu, R.id.games_group_moveup,
|
||||||
|
enable && 0 < selGroupPos );
|
||||||
|
Utils.setItemVisible( menu, R.id.games_group_movedown,
|
||||||
|
enable && (selGroupPos + 1) < m_adapter.getGroupCount() );
|
||||||
|
}
|
||||||
|
|
||||||
private static final String GROUP_POSNS_KEY = TAG + "/group_posns";
|
private static final String GROUP_POSNS_KEY = TAG + "/group_posns";
|
||||||
private void storeGroupPositions( long[] posns )
|
private void storeGroupPositions( long[] posns )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue