mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-06 20:45:54 +01:00
improve move-to-group dialog: add title and disabled Move button when
radio is current group.
This commit is contained in:
parent
a3b24be661
commit
2375f86f61
1 changed files with 26 additions and 11 deletions
|
@ -243,29 +243,34 @@ public class GamesList extends XWExpandableListActivity
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHANGE_GROUP:
|
case CHANGE_GROUP:
|
||||||
|
final long startGroup = DBUtils.getGroupForGame( this, m_rowid );
|
||||||
final int[] selItem = {-1}; // hack!!!!
|
final int[] selItem = {-1}; // hack!!!!
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlgi, int item ) {
|
||||||
selItem[0] = item;
|
selItem[0] = item;
|
||||||
|
AlertDialog dlg = (AlertDialog)dlgi;
|
||||||
|
Button btn =
|
||||||
|
dlg.getButton( AlertDialog.BUTTON_POSITIVE );
|
||||||
|
long newGroup = m_adapter.getGroupIDFor( item );
|
||||||
|
btn.setEnabled( newGroup != startGroup );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
lstnr2 = new DialogInterface.OnClickListener() {
|
lstnr2 = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
if ( -1 != selItem[0] ) {
|
Assert.assertTrue( -1 != selItem[0] );
|
||||||
long groupid =
|
long gid = m_adapter.getGroupIDFor( selItem[0] );
|
||||||
m_adapter.getGroupIDFor( selItem[0] );
|
DBUtils.moveGame( GamesList.this, m_rowid, gid );
|
||||||
DBUtils.moveGame( GamesList.this, m_rowid,
|
onContentChanged();
|
||||||
groupid );
|
|
||||||
onContentChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
String[] groups = m_adapter.groupNames();
|
String[] groups = m_adapter.groupNames();
|
||||||
long groupid = DBUtils.getGroupForGame( this, m_rowid );
|
int curGroupPos = m_adapter.getGroupPosition( startGroup );
|
||||||
int curGroupPos = m_adapter.getGroupPosition( groupid );
|
String name = GameUtils.getName( this, m_rowid );
|
||||||
dialog = new AlertDialog.Builder( this )
|
dialog = new AlertDialog.Builder( this )
|
||||||
|
.setTitle( getString( R.string.change_groupf, name ) )
|
||||||
.setSingleChoiceItems( groups, curGroupPos, lstnr )
|
.setSingleChoiceItems( groups, curGroupPos, lstnr )
|
||||||
.setPositiveButton( R.string.button_ok, lstnr2 )
|
.setPositiveButton( R.string.button_move, lstnr2 )
|
||||||
|
.setNegativeButton( R.string.button_cancel, null )
|
||||||
.create();
|
.create();
|
||||||
Utils.setRemoveOnDismiss( this, dialog, id );
|
Utils.setRemoveOnDismiss( this, dialog, id );
|
||||||
break;
|
break;
|
||||||
|
@ -306,6 +311,16 @@ public class GamesList extends XWExpandableListActivity
|
||||||
return dialog;
|
return dialog;
|
||||||
} // onCreateDialog
|
} // onCreateDialog
|
||||||
|
|
||||||
|
@Override protected void onPrepareDialog( int id, Dialog dialog )
|
||||||
|
{
|
||||||
|
super.onPrepareDialog( id, dialog );
|
||||||
|
|
||||||
|
if ( CHANGE_GROUP == id ) {
|
||||||
|
((AlertDialog)dialog).getButton( AlertDialog.BUTTON_POSITIVE )
|
||||||
|
.setEnabled( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue