mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
confirm single game delete.
This commit is contained in:
parent
5b6a5aafe8
commit
fd1ca2c9c5
2 changed files with 31 additions and 27 deletions
|
@ -185,6 +185,8 @@
|
||||||
<string name="confirm_save">This game is in play. If you
|
<string name="confirm_save">This game is in play. If you
|
||||||
save these changes it must be restarted. Do you want to save
|
save these changes it must be restarted. Do you want to save
|
||||||
these changes?</string>
|
these changes?</string>
|
||||||
|
<string name="confirm_delete">Are you sure you want to delete this
|
||||||
|
game?</string>
|
||||||
<string name="confirm_delete_all">Are you sure you want to
|
<string name="confirm_delete_all">Are you sure you want to
|
||||||
delete all games? This action cannot be undone.</string>
|
delete all games? This action cannot be undone.</string>
|
||||||
<string name="confirm_reset">Are you sure you want to reset this
|
<string name="confirm_reset">Are you sure you want to reset this
|
||||||
|
|
|
@ -274,15 +274,32 @@ public class GamesList extends XWListActivity
|
||||||
private boolean handleMenuItem( int menuID, int position )
|
private boolean handleMenuItem( int menuID, int position )
|
||||||
{
|
{
|
||||||
boolean handled = true;
|
boolean handled = true;
|
||||||
byte[] stream;
|
|
||||||
String invalPath = null;
|
|
||||||
|
|
||||||
String path = GameUtils.gamesList( this )[position];
|
final String path = GameUtils.gamesList( this )[position];
|
||||||
|
|
||||||
if ( R.id.list_item_delete == menuID ) {
|
if ( R.id.list_item_delete == menuID ) {
|
||||||
GameUtils.deleteGame( this, path );
|
DialogInterface.OnClickListener lstnr =
|
||||||
invalPath = path;
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick( DialogInterface dlg, int ii ) {
|
||||||
|
GameUtils.deleteGame( GamesList.this, path );
|
||||||
|
m_adapter.inval( path );
|
||||||
|
onContentChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
showConfirmThen( R.string.confirm_delete, lstnr );
|
||||||
|
} else if ( R.id.list_item_reset == menuID ) {
|
||||||
|
DialogInterface.OnClickListener lstnr =
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick( DialogInterface dlg, int ii ) {
|
||||||
|
GameUtils.resetGame( GamesList.this,
|
||||||
|
path, path );
|
||||||
|
m_adapter.inval( path );
|
||||||
|
onContentChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
showConfirmThen( R.string.confirm_reset, lstnr );
|
||||||
} else {
|
} else {
|
||||||
|
String invalPath = null;
|
||||||
String[] missingName = new String[1];
|
String[] missingName = new String[1];
|
||||||
int[] missingLang = new int[1];
|
int[] missingLang = new int[1];
|
||||||
boolean hasDict = GameUtils.gameDictHere( this, path,
|
boolean hasDict = GameUtils.gameDictHere( this, path,
|
||||||
|
@ -296,20 +313,6 @@ public class GamesList extends XWListActivity
|
||||||
m_invalPath = path;
|
m_invalPath = path;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.list_item_reset:
|
|
||||||
// TODO confirm_data_loss();
|
|
||||||
final String fpath = path;
|
|
||||||
DialogInterface.OnClickListener lstnr =
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick( DialogInterface dlg, int ii ) {
|
|
||||||
GameUtils.resetGame( GamesList.this,
|
|
||||||
fpath, fpath );
|
|
||||||
m_adapter.inval( fpath );
|
|
||||||
onContentChanged();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
showConfirmThen( R.string.confirm_reset, lstnr );
|
|
||||||
break;
|
|
||||||
case R.id.list_item_new_from:
|
case R.id.list_item_new_from:
|
||||||
String newName = GameUtils.resetGame( this, path );
|
String newName = GameUtils.resetGame( this, path );
|
||||||
invalPath = newName;
|
invalPath = newName;
|
||||||
|
@ -320,7 +323,7 @@ public class GamesList extends XWListActivity
|
||||||
if ( summary.inNetworkGame() ) {
|
if ( summary.inNetworkGame() ) {
|
||||||
showOKOnlyDialog( R.string.no_copy_network );
|
showOKOnlyDialog( R.string.no_copy_network );
|
||||||
} else {
|
} else {
|
||||||
stream = GameUtils.savedGame( this, path );
|
byte[] stream = GameUtils.savedGame( this, path );
|
||||||
newName = GameUtils.saveGame( this, stream );
|
newName = GameUtils.saveGame( this, stream );
|
||||||
DBUtils.saveSummary( this, newName, summary );
|
DBUtils.saveSummary( this, newName, summary );
|
||||||
}
|
}
|
||||||
|
@ -340,15 +343,14 @@ public class GamesList extends XWListActivity
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( null != invalPath ) {
|
if ( null != invalPath ) {
|
||||||
m_adapter.inval( invalPath );
|
m_adapter.inval( invalPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( handled ) {
|
if ( handled ) {
|
||||||
onContentChanged();
|
onContentChanged();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
} // handleMenuItem
|
} // handleMenuItem
|
||||||
|
|
Loading…
Add table
Reference in a new issue