make group head view selectable, and separate group and game selection

so that only one type can be selected at once.  Combine all three
menus into one, but only enable subsets equivalent to the old menus
depending on what's selected.  Snapshot: menus pretty much don't work.
This commit is contained in:
Eric House 2013-10-18 20:40:20 -07:00
parent 9fe34e4183
commit 43e69c7627
8 changed files with 311 additions and 257 deletions

View file

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/list_group_default"
android:title="@string/list_group_default"
/>
<item android:id="@+id/list_group_rename"
android:title="@string/list_group_rename"
/>
<item android:id="@+id/list_group_moveup"
android:title="@string/list_group_moveup"
/>
<item android:id="@+id/list_group_movedown"
android:title="@string/list_group_movedown"
/>
<item android:id="@+id/list_group_delete"
android:title="@string/list_group_delete"
/>
</menu>

View file

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/list_item_rename"
android:title="@string/list_item_rename"
/>
<item android:id="@+id/list_item_move"
android:title="@string/list_item_move"
/>
<item android:id="@+id/list_item_reset"
android:title="@string/list_item_reset"
/>
<item android:id="@+id/list_item_new_from"
android:title="@string/list_item_new_from"
/>
<item android:id="@+id/list_item_copy"
android:title="@string/list_item_copy"
/>
<item android:title="(rest deprecated)"/>
<item android:id="@+id/list_item_delete"
android:title="@string/list_item_delete"
/>
<item android:id="@+id/list_item_config"
android:title="@string/list_item_config"
/>
<!-- <item android:id="@+id/list_item_hide" -->
<!-- android:title="@string/list_item_hide" -->
<!-- /> -->
<!-- <item android:id="@+id/list_item_move_up" -->
<!-- android:title="@string/list_item_move_up" -->
<!-- /> -->
<!-- <item android:id="@+id/list_item_move_down" -->
<!-- android:title="@string/list_item_move_down" -->
<!-- /> -->
<!-- <item android:id="@+id/list_item_move_to_top" -->
<!-- android:title="@string/list_item_move_to_top" -->
<!-- /> -->
<!-- <item android:id="@+id/list_item_move_to_bottom" -->
<!-- android:title="@string/list_item_move_to_bottom" -->
<!-- /> -->
</menu>

View file

@ -11,6 +11,13 @@
android:icon="@drawable/ic_action_delete"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/list_group_delete"
android:title="@string/list_group_delete"
android:icon="@drawable/ic_action_delete"
android:showAsAction="ifRoom"
/>
<item android:id="@+id/listl_item_config"
android:title="@string/list_item_config"
android:icon="@drawable/content_edit"
@ -42,6 +49,38 @@
android:title="@string/gamel_menu_checkmoves"
android:icon="@drawable/stat_notify_sync"
/>
<!-- Game items -->
<item android:id="@+id/list_item_rename"
android:title="@string/list_item_rename"
/>
<item android:id="@+id/list_item_move"
android:title="@string/list_item_move"
/>
<item android:id="@+id/list_item_reset"
android:title="@string/list_item_reset"
/>
<item android:id="@+id/list_item_new_from"
android:title="@string/list_item_new_from"
/>
<item android:id="@+id/list_item_copy"
android:title="@string/list_item_copy"
/>
<!-- Group items -->
<item android:id="@+id/list_group_default"
android:title="@string/list_group_default"
/>
<item android:id="@+id/list_group_rename"
android:title="@string/list_group_rename"
/>
<item android:id="@+id/list_group_moveup"
android:title="@string/list_group_moveup"
/>
<item android:id="@+id/list_group_movedown"
android:title="@string/list_group_movedown"
/>
<!-- Debug only menuitems -->
<item android:id="@+id/gamel_menu_checkupdates"
android:title="@string/gamel_menu_checkupdates"
@ -53,5 +92,4 @@
android:title="@string/gamel_menu_loaddb"
/>
<!-- ic_menu_archive.png -->
</menu>

View file

@ -21,6 +21,7 @@ package org.eehouse.android.xw4;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.widget.TextView;
@ -28,6 +29,8 @@ import android.widget.TextView;
class ExpiringTextView extends TextView {
private ExpiringDelegate m_delegate = null;
private Context m_context;
private Drawable m_origDrawable;
protected boolean m_selected = false;
public ExpiringTextView( Context context, AttributeSet attrs )
{
@ -52,6 +55,17 @@ class ExpiringTextView extends TextView {
}
}
protected void toggleSelected()
{
m_selected = !m_selected;
if ( m_selected ) {
m_origDrawable = getBackground();
setBackgroundColor( XWApp.SEL_COLOR );
} else {
setBackgroundDrawable( m_origDrawable );
}
}
@Override
protected void onDraw( Canvas canvas )
{

View file

@ -49,11 +49,15 @@ public class GameListAdapter implements ExpandableListAdapter {
private long[] m_positions;
public interface LoadItemCB {
public void itemClicked( long rowid, GameSummary summary );
public void itemToggled( long rowid, boolean selected );
public void itemClicked( Object clicked, GameSummary summary );
public void itemToggled( Object toggled, boolean selected );
public boolean getSelected( long rowid );
}
public interface ClickHandler {
public void longClicked();
}
public GameListAdapter( Context context, ExpandableListView list,
Handler handler, LoadItemCB cb, long[] positions,
String fieldName )
@ -152,9 +156,14 @@ public class GameListAdapter implements ExpandableListAdapter {
return ggi.m_name;
}
public void clearSelected( Set<Long> rowids )
public void clearSelectedRows( Set<Long> rowids )
{
deselect( rowids );
deselectRows( rowids );
}
public void clearSelectedGroups( HashSet<Integer> groups )
{
deselectGroups( groups );
}
//////////////////////////////////////////////////////////////////////////
@ -182,7 +191,7 @@ public class GameListAdapter implements ExpandableListAdapter {
for ( long rowid : rowids ) {
asSet.add( rowid );
}
deselect( asSet );
deselectRows( asSet );
}
public void onGroupExpanded( int groupPosition )
@ -232,9 +241,8 @@ public class GameListAdapter implements ExpandableListAdapter {
// if ( null != convertView ) {
// DbgUtils.logf( "getGroupView gave non-null convertView" );
// }
GameListGroup view = (GameListGroup)
Utils.inflate(m_context, R.layout.game_list_group );
view.setGroupPosition( groupPosition );
GameListGroup view =
GameListGroup.makeForPosition( m_context, groupPosition, m_cb );
if ( !isExpanded ) {
GameGroupInfo ggi = getInfoForGroup( groupPosition );
@ -364,7 +372,7 @@ public class GameListAdapter implements ExpandableListAdapter {
return gameInfo().get( getPositions()[groupPosition] );
}
private void deselect( Set<Long> rowids )
private void deselectRows( Set<Long> rowids )
{
GameListItem[] items = new GameListItem[rowids.size()];
getGameItemsFor( rowids, items );
@ -375,6 +383,16 @@ public class GameListAdapter implements ExpandableListAdapter {
}
}
private void deselectGroups( HashSet<Integer> groups )
{
groups = (HashSet<Integer>)groups.clone();
for ( Iterator<Integer>iter = groups.iterator();
iter.hasNext(); ) {
GameListGroup group = getGroupItemFor( iter.next() );
group.setSelected( false );
}
}
private void getGameItemsFor( Set<Long> rowids, GameListItem[] items )
{
int next = 0;

View file

@ -23,11 +23,27 @@ package org.eehouse.android.xw4;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
import org.eehouse.android.xw4.DBUtils.GameGroupInfo;
public class GameListGroup extends ExpiringTextView {
public class GameListGroup extends ExpiringTextView
implements GameListAdapter.ClickHandler
{
private int m_groupPosition;
private boolean m_expanded;
private GameListAdapter.LoadItemCB m_cb;
public static GameListGroup makeForPosition( Context context,
int groupPosition,
GameListAdapter.LoadItemCB cb )
{
GameListGroup result =
(GameListGroup)Utils.inflate( context, R.layout.game_list_group );
result.m_cb = cb;
result.m_groupPosition = groupPosition;
return result;
}
public GameListGroup( Context cx, AttributeSet as )
{
@ -43,4 +59,25 @@ public class GameListGroup extends ExpiringTextView {
{
return m_groupPosition;
}
public void setSelected( boolean selected )
{
// If new value and state not in sync, force change in state
if ( selected != m_selected ) {
toggleSelected();
}
}
// GameListAdapter.ClickHandler interface
public void longClicked()
{
toggleSelected();
}
protected void toggleSelected()
{
super.toggleSelected();
m_cb.itemToggled( this, m_selected );
}
}

View file

@ -43,7 +43,7 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.GameSummary;
public class GameListItem extends LinearLayout
implements View.OnClickListener {
implements View.OnClickListener, GameListAdapter.ClickHandler {
private static HashSet<Long> s_invalRows = new HashSet<Long>();
@ -62,6 +62,7 @@ public class GameListItem extends LinearLayout
private int m_loadingCount;
private int m_groupPosition;
private Drawable m_origDrawable;
private boolean m_selected = false;
public GameListItem( Context cx, AttributeSet as )
{
@ -71,6 +72,18 @@ public class GameListItem extends LinearLayout
m_rowid = DBUtils.ROWID_NOTFOUND;
m_lastMoveTime = 0;
m_loadingCount = 0;
setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View v ) {
// if selected, just un-select
if ( m_selected ) {
toggleSelected();
} else if ( null != m_summary ) {
m_cb.itemClicked( this, m_summary );
}
}
} );
}
private void init( Handler handler, long rowid, int groupPosition,
@ -105,7 +118,7 @@ public class GameListItem extends LinearLayout
public void setSelected( boolean selected )
{
// If new value and state not in sync, force change in state
if ( selected != (null != m_origDrawable) ) {
if ( selected != m_selected ) {
toggleSelected();
}
}
@ -214,24 +227,12 @@ public class GameListItem extends LinearLayout
return state;
}
private void setData( final GameSummary summary )
private void setData( GameSummary summary )
{
if ( null != summary ) {
TextView tview;
String state = setName();
setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View v ) {
// if selected, just un-select
if ( null != m_origDrawable ) {
toggleSelected();
} else {
m_cb.itemClicked( m_rowid, summary );
}
}
} );
LinearLayout list =
(LinearLayout)findViewById( R.id.player_list );
list.removeAllViews();
@ -305,14 +306,14 @@ public class GameListItem extends LinearLayout
private void toggleSelected()
{
if ( null == m_origDrawable ) {
m_selected = !m_selected;
if ( m_selected ) {
m_origDrawable = getBackground();
setBackgroundColor( XWApp.SEL_COLOR );
} else {
setBackgroundDrawable( m_origDrawable );
m_origDrawable = null;
}
m_cb.itemToggled( m_rowid, null != m_origDrawable );
m_cb.itemToggled( this, m_selected );
}
private class LoadItemTask extends AsyncTask<Void, Void, GameSummary> {
@ -334,7 +335,7 @@ public class GameListItem extends LinearLayout
}
}
if ( m_cb.getSelected( m_rowid ) && null != m_origDrawable ) {
if ( m_cb.getSelected( m_rowid ) && m_selected ) {
toggleSelected();
}
}
@ -372,5 +373,11 @@ public class GameListItem extends LinearLayout
// }
// return TextUtils.join(",", strs );
// }
// GameListAdapter.ClickHandler interface
public void longClicked()
{
toggleSelected();
}
}

View file

@ -32,16 +32,15 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
// import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ExpandableListView;
import android.widget.LinearLayout;
import android.widget.ListView;
@ -59,7 +58,8 @@ import junit.framework.Assert;
import org.eehouse.android.xw4.jni.*;
public class GamesList extends XWExpandableListActivity
implements DBUtils.DBChangeListener,
implements OnItemLongClickListener,
DBUtils.DBChangeListener,
GameListAdapter.LoadItemCB,
DictImportActivity.DownloadFinishedListener {
@ -91,9 +91,32 @@ public class GamesList extends XWExpandableListActivity
DELETE_SELGAMES,
OPEN_GAME
};
private static final int[] DEBUGITEMS = { R.id.gamel_menu_loaddb
, R.id.gamel_menu_storedb
, R.id.gamel_menu_checkupdates
private static final int[] DEBUGITEMS = {
R.id.gamel_menu_loaddb
, R.id.gamel_menu_storedb
, R.id.gamel_menu_checkupdates
};
private static final int[] NOSEL_ITEMS = {
R.id.gamel_menu_newgame
,R.id.gamel_menu_newgroup
,R.id.gamel_menu_prefs
,R.id.gamel_menu_dicts
,R.id.gamel_menu_about
,R.id.gamel_menu_email
,R.id.gamel_menu_checkmoves
};
private static final int[] ONEGAME_ITEMS = {
R.id.listl_item_config
,R.id.list_item_rename
,R.id.list_item_new_from
,R.id.list_item_copy
};
private static final int[] ONEGROUP_ITEMS = {
R.id.list_group_default
,R.id.list_group_rename
,R.id.list_group_moveup
,R.id.list_group_movedown
};
private static boolean s_firstShown = false;
@ -110,7 +133,8 @@ public class GamesList extends XWExpandableListActivity
private NetLaunchInfo m_netLaunchInfo;
private GameNamer m_namer;
private boolean m_gameLaunched = false;
private HashSet<Long> m_selected;
private HashSet<Long> m_selectedRows;
private HashSet<Integer> m_selectedGroups;
@Override
protected Dialog onCreateDialog( int id )
@ -339,10 +363,11 @@ public class GamesList extends XWExpandableListActivity
getBundledData( savedInstanceState );
m_selected = new HashSet<Long>();
m_selectedRows = new HashSet<Long>();
m_selectedGroups = new HashSet<Integer>();
setContentView(R.layout.game_list);
registerForContextMenu( getExpandableListView() );
ExpandableListView listview = getExpandableListView();
DBUtils.setDBChangeListener( this );
boolean isUpgrade = Utils.firstBootThisVersion( this );
@ -354,11 +379,12 @@ public class GamesList extends XWExpandableListActivity
String field = CommonPrefs.getSummaryField( this );
long[] positions = XWPrefs.getGroupPositions( this );
m_adapter = new GameListAdapter( this, getExpandableListView(),
new Handler(), this, positions,
field );
m_adapter = new GameListAdapter( this, listview, new Handler(),
this, positions, field );
setListAdapter( m_adapter );
m_adapter.expandGroups( getExpandableListView() );
listview.setOnItemLongClickListener( this );
m_adapter.expandGroups( listview );
NetUtils.informOfDeaths( this );
@ -431,6 +457,16 @@ public class GamesList extends XWExpandableListActivity
}
}
// OnItemLongClickListener interface
public boolean onItemLongClick( AdapterView<?> parent, View view,
int position, long id ) {
boolean success = view instanceof GameListAdapter.ClickHandler;
if ( success ) {
((GameListAdapter.ClickHandler)view).longClicked();
}
return success;
}
// DBUtils.DBChangeListener interface
public void gameSaved( final long rowid, final boolean countChanged )
{
@ -446,33 +482,47 @@ public class GamesList extends XWExpandableListActivity
}
// GameListAdapter.LoadItemCB interface
public void itemClicked( long rowid, GameSummary summary )
public void itemClicked( Object clicked, GameSummary summary )
{
// We need a way to let the user get back to the basic-config
// dialog in case it was dismissed. That way it to check for
// an empty room name.
if ( !m_gameLaunched ) {
showNotAgainDlgThen( R.string.not_again_newselect,
R.string.key_notagain_newselect,
GamesActions.OPEN_GAME.ordinal(),
rowid, summary );
if ( clicked instanceof GameListItem ) {
if ( !m_gameLaunched ) {
long rowid = ((GameListItem)clicked).getRowID();
showNotAgainDlgThen( R.string.not_again_newselect,
R.string.key_notagain_newselect,
GamesActions.OPEN_GAME.ordinal(),
rowid, summary );
}
}
}
public void itemToggled( long rowid, boolean selected )
public void itemToggled( Object toggled, boolean selected )
{
int countBefore = m_selected.size();
if ( selected ) {
m_selected.add( rowid );
} else {
m_selected.remove( rowid );
if ( toggled instanceof GameListItem ) {
long rowid = ((GameListItem)toggled).getRowID();
if ( selected ) {
m_selectedRows.add( rowid );
clearSelectedGroups();
} else {
m_selectedRows.remove( rowid );
}
} else if ( toggled instanceof GameListGroup ) {
int position = ((GameListGroup)toggled).getGroupPosition();
if ( selected ) {
m_selectedGroups.add( position );
clearSelectedRows();
} else {
m_selectedGroups.remove( position );
}
}
Utils.invalidateOptionsMenuIf( this );
}
public boolean getSelected( long rowid )
{
return m_selected.contains( rowid );
return m_selectedRows.contains( rowid );
}
// BTService.MultiEventListener interface
@ -548,77 +598,13 @@ public class GamesList extends XWExpandableListActivity
@Override
public void onBackPressed() {
if ( 0 == m_selected.size() ) {
if ( 0 == m_selectedRows.size() ) {
super.onBackPressed();
} else {
clearSelected();
clearSelectedRows();
}
}
@Override
public void onCreateContextMenu( ContextMenu menu, View view,
ContextMenuInfo menuInfo )
{
ExpandableListView.ExpandableListContextMenuInfo info
= (ExpandableListView.ExpandableListContextMenuInfo)menuInfo;
long packedPos = info.packedPosition;
int childPos = ExpandableListView.getPackedPositionChild( packedPos );
String name;
if ( 0 <= childPos ) { // game case
MenuInflater inflater = getMenuInflater();
inflater.inflate( R.menu.games_list_item_menu, menu );
long rowid = m_adapter.getRowIDFor( packedPos );
name = GameUtils.getName( this, rowid );
} else { // group case
MenuInflater inflater = getMenuInflater();
inflater.inflate( R.menu.games_list_group_menu, menu );
int pos = ExpandableListView.getPackedPositionGroup( packedPos );
name = m_adapter.groupNames()[pos];
if ( 0 == pos ) {
Utils.setItemEnabled( menu, R.id.list_group_moveup, false );
}
if ( pos + 1 == m_adapter.getGroupCount() ) {
Utils.setItemEnabled( menu, R.id.list_group_movedown, false );
}
if ( XWPrefs.getDefaultNewGameGroup( this )
== m_adapter.getGroupIDFor( pos ) ) {
Utils.setItemEnabled( menu, R.id.list_group_default, false );
Utils.setItemEnabled( menu, R.id.list_group_delete, false );
}
}
menu.setHeaderTitle( getString( R.string.game_item_menu_titlef,
name ) );
}
@Override
public boolean onContextItemSelected( MenuItem item )
{
ExpandableListContextMenuInfo info;
try {
info = (ExpandableListContextMenuInfo)item.getMenuInfo();
} catch (ClassCastException cce) {
DbgUtils.loge( cce );
return false;
}
long packedPos = info.packedPosition;
int childPos = ExpandableListView.getPackedPositionChild( packedPos );
int groupPos = ExpandableListView.getPackedPositionGroup(packedPos);
int menuID = item.getItemId();
boolean handled;
if ( 0 <= childPos ) {
long rowid = m_adapter.getRowIDFor( groupPos, childPos );
handled = handleGameMenuItem( menuID, rowid );
} else {
handled = handleGroupMenuItem( menuID, groupPos );
}
return handled;
} // onContextItemSelected
@Override
public boolean onCreateOptionsMenu( Menu menu )
{
@ -631,22 +617,38 @@ public class GamesList extends XWExpandableListActivity
@Override
public boolean onPrepareOptionsMenu( Menu menu )
{
int nGamesSelected = m_selectedRows.size();
int nGroupsSelected = m_selectedGroups.size();
boolean nothingSelected = 0 == (nGroupsSelected + nGamesSelected);
Assert.assertTrue( 0 == nGamesSelected || 0 == nGroupsSelected );
boolean visible = XWPrefs.getDebugEnabled( this );
for ( int id : DEBUGITEMS ) {
MenuItem item = menu.findItem( id );
item.setVisible( visible );
Utils.setItemVisible( menu, id, nothingSelected && visible );
}
if ( visible && !DBUtils.gameDBExists( this ) ) {
MenuItem item = menu.findItem( R.id.gamel_menu_loaddb );
item.setVisible( false );
Utils.setItemVisible( menu, R.id.gamel_menu_loaddb, false );
}
int nSelected = m_selected.size();
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 );
}
Utils.setItemVisible( menu, R.id.gamel_menu_newgame, 0 == nSelected );
Utils.setItemVisible( menu, R.id.gamel_menu_delete, 0 < nSelected );
Utils.setItemVisible( menu, R.id.listl_item_config, 1 == nSelected );
// Multiples can be deleted
Utils.setItemVisible( menu, R.id.gamel_menu_delete,
0 < nGamesSelected );
Utils.setItemVisible( menu, R.id.list_group_delete,
0 < nGroupsSelected );
// multiple games can be regrouped/reset
Utils.setItemVisible( menu, R.id.list_item_move, 0 < nGroupsSelected );
Utils.setItemVisible( menu, R.id.list_item_reset, 0 < nGroupsSelected );
return super.onPrepareOptionsMenu( menu );
}
@ -665,13 +667,13 @@ public class GamesList extends XWExpandableListActivity
break;
case R.id.listl_item_config:
long rowid = m_selected.iterator().next();
long rowid = m_selectedRows.iterator().next();
GameUtils.doConfig( this, rowid, GameConfig.class );
break;
case R.id.gamel_menu_delete:
String msg = Utils.format( this, R.string.confirm_seldeletesf,
m_selected.size() );
m_selectedRows.size() );
showConfirmThen( msg, R.string.button_delete,
GamesActions.DELETE_SELGAMES.ordinal() );
break;
@ -745,61 +747,53 @@ public class GamesList extends XWExpandableListActivity
m_rowid = rowid;
if ( R.id.list_item_delete == menuID
|| R.id.list_item_config == menuID ) {
showOKOnlyDialog( "This menu item is going away soon. Please select"
+ " games by tapping the left icons then use"
+ " action bar icons or the screen menu to operate"
+ " on the selection." );
} else {
if ( checkWarnNoDict( m_rowid ) ) {
switch ( menuID ) {
case R.id.list_item_reset:
showConfirmThen( R.string.confirm_reset,
R.string.button_reset,
GamesActions.RESET_GAME.ordinal() );
break;
case R.id.list_item_rename:
showDialog( RENAME_GAME );
break;
case R.id.list_item_move:
if ( 1 >= m_adapter.getGroupCount() ) {
showOKOnlyDialog( R.string.no_move_onegroup );
} else {
showDialog( CHANGE_GROUP );
}
break;
case R.id.list_item_new_from:
showNotAgainDlgThen( R.string.not_again_newfrom,
R.string.key_notagain_newfrom,
GamesActions.NEW_FROM.ordinal() );
break;
case R.id.list_item_copy:
GameSummary summary = DBUtils.getSummary( this, m_rowid );
if ( summary.inNetworkGame() ) {
showOKOnlyDialog( R.string.no_copy_network );
} else {
byte[] stream = GameUtils.savedGame( this, m_rowid );
GameLock lock = GameUtils.saveNewGame( this, stream );
DBUtils.saveSummary( this, lock, summary );
lock.unlock();
}
break;
// These require some notion of predictable sort order.
// Maybe put off until I'm using a db?
// case R.id.list_item_hide:
// case R.id.list_item_move_up:
// case R.id.list_item_move_down:
// case R.id.list_item_move_to_top:
// case R.id.list_item_move_to_bottom:
// Utils.notImpl( this );
// break;
default:
handled = false;
break;
if ( checkWarnNoDict( m_rowid ) ) {
switch ( menuID ) {
case R.id.list_item_reset:
showConfirmThen( R.string.confirm_reset,
R.string.button_reset,
GamesActions.RESET_GAME.ordinal() );
break;
case R.id.list_item_rename:
showDialog( RENAME_GAME );
break;
case R.id.list_item_move:
if ( 1 >= m_adapter.getGroupCount() ) {
showOKOnlyDialog( R.string.no_move_onegroup );
} else {
showDialog( CHANGE_GROUP );
}
break;
case R.id.list_item_new_from:
showNotAgainDlgThen( R.string.not_again_newfrom,
R.string.key_notagain_newfrom,
GamesActions.NEW_FROM.ordinal() );
break;
case R.id.list_item_copy:
GameSummary summary = DBUtils.getSummary( this, m_rowid );
if ( summary.inNetworkGame() ) {
showOKOnlyDialog( R.string.no_copy_network );
} else {
byte[] stream = GameUtils.savedGame( this, m_rowid );
GameLock lock = GameUtils.saveNewGame( this, stream );
DBUtils.saveSummary( this, lock, summary );
lock.unlock();
}
break;
// These require some notion of predictable sort order.
// Maybe put off until I'm using a db?
// case R.id.list_item_hide:
// case R.id.list_item_move_up:
// case R.id.list_item_move_down:
// case R.id.list_item_move_to_top:
// case R.id.list_item_move_to_bottom:
// Utils.notImpl( this );
// break;
default:
handled = false;
break;
}
}
@ -1076,11 +1070,11 @@ public class GamesList extends XWExpandableListActivity
private void deleteSelected()
{
for ( Iterator<Long> iter = m_selected.iterator(); iter.hasNext(); ) {
for ( Iterator<Long> iter = m_selectedRows.iterator(); iter.hasNext(); ) {
long rowid = iter.next();
GameUtils.deleteGame( this, rowid, false );
}
m_selected.clear();
m_selectedRows.clear();
Utils.invalidateOptionsMenuIf( this );
NetUtils.informOfDeaths( this );
}
@ -1095,12 +1089,21 @@ public class GamesList extends XWExpandableListActivity
return madeGame;
}
private void clearSelected()
private void clearSelectedRows()
{
// clear any selection
if ( 0 < m_selected.size() ) {
m_adapter.clearSelected( m_selected );
m_selected.clear();
if ( 0 < m_selectedRows.size() ) {
m_adapter.clearSelectedRows( m_selectedRows );
m_selectedRows.clear();
}
}
private void clearSelectedGroups()
{
// clear any selection
if ( 0 < m_selectedGroups.size() ) {
m_adapter.clearSelectedGroups( m_selectedGroups );
m_selectedGroups.clear();
}
}
@ -1119,7 +1122,7 @@ public class GamesList extends XWExpandableListActivity
if ( !m_gameLaunched ) {
m_gameLaunched = true;
GameUtils.launchGame( this, rowid, invited );
clearSelected();
clearSelectedRows();
}
}