implement delete of selected games with confirmation

This commit is contained in:
Eric House 2013-10-13 20:33:55 -07:00
parent e7a23afc4a
commit ac229e4ae7
2 changed files with 23 additions and 0 deletions

View file

@ -179,6 +179,9 @@
<string name="confirm_delete">Are you sure you want to delete this
game?</string>
<string name="confirm_seldeletes">Are you sure you want to delete
all selected games? This action cannot be undone.</string>
<!-- Text of confirmation dialog posted when list_item_reset menu
is selected -->
<string name="confirm_reset">Are you sure you want to reset this

View file

@ -88,6 +88,7 @@ public class GamesList extends XWExpandableListActivity
private static final int SYNC_MENU_ACTION = 4;
private static final int NEW_FROM_ACTION = 5;
private static final int DELETE_GROUP_ACTION = 6;
private static final int DELETE_SELGAMES_ACTION = 7;
private static final int[] DEBUGITEMS = { R.id.gamel_menu_loaddb
, R.id.gamel_menu_storedb
, R.id.gamel_menu_checkupdates
@ -587,6 +588,9 @@ public class GamesList extends XWExpandableListActivity
GameUtils.deleteGroup( this, m_groupid );
onContentChanged();
break;
case DELETE_SELGAMES_ACTION:
deleteSelected();
break;
default:
Assert.fail();
}
@ -708,6 +712,11 @@ public class GamesList extends XWExpandableListActivity
showDialog( NEW_GROUP );
break;
case R.id.gamel_menu_delete:
showConfirmThen( R.string.confirm_seldeletes, R.string.button_delete,
DELETE_SELGAMES_ACTION );
break;
case R.id.gamel_menu_dicts:
DictsActivity.start( this );
break;
@ -1105,6 +1114,17 @@ public class GamesList extends XWExpandableListActivity
return dialog;
}
private void deleteSelected()
{
for ( Iterator<Long> iter = m_selected.iterator(); iter.hasNext(); ) {
long rowid = iter.next();
GameUtils.deleteGame( this, rowid, false );
}
m_selected.clear();
NetUtils.informOfDeaths( this );
}
private boolean makeNewNetGameIf()
{
boolean madeGame = null != m_netLaunchInfo;