mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-31 19:57:06 +01:00
support moving multiple groups
This commit is contained in:
parent
ab3209ca70
commit
6759a5af95
1 changed files with 20 additions and 8 deletions
|
@ -74,6 +74,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
private static final int WARN_NODICT_NEW = WARN_NODICT + 8;
|
private static final int WARN_NODICT_NEW = WARN_NODICT + 8;
|
||||||
|
|
||||||
private static final String SAVE_ROWID = "SAVE_ROWID";
|
private static final String SAVE_ROWID = "SAVE_ROWID";
|
||||||
|
private static final String SAVE_ROWIDS = "SAVE_ROWIDS";
|
||||||
private static final String SAVE_GROUPID = "SAVE_GROUPID";
|
private static final String SAVE_GROUPID = "SAVE_GROUPID";
|
||||||
private static final String SAVE_DICTNAMES = "SAVE_DICTNAMES";
|
private static final String SAVE_DICTNAMES = "SAVE_DICTNAMES";
|
||||||
|
|
||||||
|
@ -125,6 +126,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
private String[] m_sameLangDicts;
|
private String[] m_sameLangDicts;
|
||||||
private int m_missingDictLang;
|
private int m_missingDictLang;
|
||||||
private long m_rowid;
|
private long m_rowid;
|
||||||
|
private long[] m_rowids;
|
||||||
private long m_groupid;
|
private long m_groupid;
|
||||||
private String m_nameField;
|
private String m_nameField;
|
||||||
private NetLaunchInfo m_netLaunchInfo;
|
private NetLaunchInfo m_netLaunchInfo;
|
||||||
|
@ -275,7 +277,8 @@ public class GamesList extends XWExpandableListActivity
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHANGE_GROUP:
|
case CHANGE_GROUP:
|
||||||
final long startGroup = DBUtils.getGroupForGame( this, m_rowid );
|
final long startGroup = ( 1 == m_rowids.length )
|
||||||
|
? DBUtils.getGroupForGame( this, m_rowids[0] ) : -1;
|
||||||
final int[] selItem = {-1}; // hack!!!!
|
final int[] selItem = {-1}; // hack!!!!
|
||||||
lstnr = new DialogInterface.OnClickListener() {
|
lstnr = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlgi, int item ) {
|
public void onClick( DialogInterface dlgi, int item ) {
|
||||||
|
@ -283,23 +286,28 @@ public class GamesList extends XWExpandableListActivity
|
||||||
AlertDialog dlg = (AlertDialog)dlgi;
|
AlertDialog dlg = (AlertDialog)dlgi;
|
||||||
Button btn =
|
Button btn =
|
||||||
dlg.getButton( AlertDialog.BUTTON_POSITIVE );
|
dlg.getButton( AlertDialog.BUTTON_POSITIVE );
|
||||||
long newGroup = m_adapter.getGroupIDFor( item );
|
boolean enabled = startGroup == -1;
|
||||||
btn.setEnabled( newGroup != startGroup );
|
if ( !enabled ) {
|
||||||
|
long newGroup = m_adapter.getGroupIDFor( item );
|
||||||
|
enabled = newGroup != startGroup;
|
||||||
|
}
|
||||||
|
btn.setEnabled( enabled );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
lstnr2 = new DialogInterface.OnClickListener() {
|
lstnr2 = new DialogInterface.OnClickListener() {
|
||||||
public void onClick( DialogInterface dlg, int item ) {
|
public void onClick( DialogInterface dlg, int item ) {
|
||||||
Assert.assertTrue( -1 != selItem[0] );
|
Assert.assertTrue( -1 != selItem[0] );
|
||||||
long gid = m_adapter.getGroupIDFor( selItem[0] );
|
long gid = m_adapter.getGroupIDFor( selItem[0] );
|
||||||
DBUtils.moveGame( GamesList.this, m_rowid, gid );
|
for ( long rowid : m_rowids ) {
|
||||||
|
DBUtils.moveGame( GamesList.this, rowid, gid );
|
||||||
|
}
|
||||||
onContentChanged();
|
onContentChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
String[] groups = m_adapter.groupNames();
|
String[] groups = m_adapter.groupNames();
|
||||||
int curGroupPos = m_adapter.getGroupPosition( startGroup );
|
int curGroupPos = m_adapter.getGroupPosition( startGroup );
|
||||||
String name = GameUtils.getName( this, m_rowid );
|
|
||||||
dialog = new AlertDialog.Builder( this )
|
dialog = new AlertDialog.Builder( this )
|
||||||
.setTitle( getString( R.string.change_groupf, name ) )
|
.setTitle( getString( R.string.change_group ) )
|
||||||
.setSingleChoiceItems( groups, curGroupPos, lstnr )
|
.setSingleChoiceItems( groups, curGroupPos, lstnr )
|
||||||
.setPositiveButton( R.string.button_move, lstnr2 )
|
.setPositiveButton( R.string.button_move, lstnr2 )
|
||||||
.setNegativeButton( R.string.button_cancel, null )
|
.setNegativeButton( R.string.button_cancel, null )
|
||||||
|
@ -431,6 +439,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
{
|
{
|
||||||
super.onSaveInstanceState( outState );
|
super.onSaveInstanceState( outState );
|
||||||
outState.putLong( SAVE_ROWID, m_rowid );
|
outState.putLong( SAVE_ROWID, m_rowid );
|
||||||
|
outState.putLongArray( SAVE_ROWIDS, m_rowids );
|
||||||
outState.putLong( SAVE_GROUPID, m_groupid );
|
outState.putLong( SAVE_GROUPID, m_groupid );
|
||||||
outState.putString( SAVE_DICTNAMES, m_missingDictName );
|
outState.putString( SAVE_DICTNAMES, m_missingDictName );
|
||||||
if ( null != m_netLaunchInfo ) {
|
if ( null != m_netLaunchInfo ) {
|
||||||
|
@ -442,6 +451,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
{
|
{
|
||||||
if ( null != bundle ) {
|
if ( null != bundle ) {
|
||||||
m_rowid = bundle.getLong( SAVE_ROWID );
|
m_rowid = bundle.getLong( SAVE_ROWID );
|
||||||
|
m_rowids = bundle.getLongArray( SAVE_ROWIDS );
|
||||||
m_groupid = bundle.getLong( SAVE_GROUPID );
|
m_groupid = bundle.getLong( SAVE_GROUPID );
|
||||||
m_netLaunchInfo = new NetLaunchInfo( bundle );
|
m_netLaunchInfo = new NetLaunchInfo( bundle );
|
||||||
m_missingDictName = bundle.getString( SAVE_DICTNAMES );
|
m_missingDictName = bundle.getString( SAVE_DICTNAMES );
|
||||||
|
@ -681,7 +691,9 @@ public class GamesList extends XWExpandableListActivity
|
||||||
0 < nGroupsSelected );
|
0 < nGroupsSelected );
|
||||||
|
|
||||||
// multiple games can be regrouped/reset. (Later....)
|
// multiple games can be regrouped/reset. (Later....)
|
||||||
Utils.setItemVisible( menu, R.id.list_item_move, 1 == nGamesSelected );
|
Utils.setItemVisible( menu, R.id.list_item_move,
|
||||||
|
(1 < m_adapter.getGroupCount()
|
||||||
|
&& 0 < nGamesSelected) );
|
||||||
Utils.setItemVisible( menu, R.id.list_item_reset, 1 == nGamesSelected );
|
Utils.setItemVisible( menu, R.id.list_item_reset, 1 == nGamesSelected );
|
||||||
|
|
||||||
m_menuPrepared = super.onPrepareOptionsMenu( menu );
|
m_menuPrepared = super.onPrepareOptionsMenu( menu );
|
||||||
|
@ -768,7 +780,7 @@ public class GamesList extends XWExpandableListActivity
|
||||||
if ( 1 >= m_adapter.getGroupCount() ) {
|
if ( 1 >= m_adapter.getGroupCount() ) {
|
||||||
showOKOnlyDialog( R.string.no_move_onegroup );
|
showOKOnlyDialog( R.string.no_move_onegroup );
|
||||||
} else {
|
} else {
|
||||||
m_rowid = selRowIDs[0];
|
m_rowids = selRowIDs;
|
||||||
showDialog( CHANGE_GROUP );
|
showDialog( CHANGE_GROUP );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue