mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-01 19:57:11 +01:00
disable move when all games already there
When all selected games are starting in the same group and that group is selected as the move destination, disable the move button.
This commit is contained in:
parent
b8e8c176ed
commit
afb0c1d3ee
1 changed files with 34 additions and 15 deletions
|
@ -80,7 +80,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
|
|
||||||
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";
|
||||||
private static final String SAVE_NEXTSOLO = "SAVE_NEXTSOLO";
|
private static final String SAVE_NEXTSOLO = "SAVE_NEXTSOLO";
|
||||||
|
@ -587,7 +586,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
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;
|
||||||
|
@ -766,9 +764,20 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHANGE_GROUP:
|
case CHANGE_GROUP:
|
||||||
final long startGroup = ( 1 == m_rowids.length )
|
long srcGroup = -1;
|
||||||
? DBUtils.getGroupForGame( m_activity, m_rowids[0] ) : -1;
|
// If all games are coming from the same group we can disable move
|
||||||
final int[] selItem = {-1}; // hack!!!!
|
// when that's the destination
|
||||||
|
for ( long rowid : m_selGames ) {
|
||||||
|
long groupID = DBUtils.getGroupForGame( m_activity, rowid );
|
||||||
|
if ( -1 == srcGroup ) {
|
||||||
|
srcGroup = groupID;
|
||||||
|
} else if ( srcGroup != groupID ) {
|
||||||
|
srcGroup = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final int[] selItem = {-1};
|
||||||
|
final long fSrcGroup = srcGroup;;
|
||||||
lstnr = new OnClickListener() {
|
lstnr = new OnClickListener() {
|
||||||
public void onClick( DialogInterface dlgi, int item ) {
|
public void onClick( DialogInterface dlgi, int item ) {
|
||||||
GamesListDelegate self = curThis();
|
GamesListDelegate self = curThis();
|
||||||
|
@ -776,10 +785,10 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
AlertDialog dlg = (AlertDialog)dlgi;
|
AlertDialog dlg = (AlertDialog)dlgi;
|
||||||
Button btn =
|
Button btn =
|
||||||
dlg.getButton( AlertDialog.BUTTON_POSITIVE );
|
dlg.getButton( AlertDialog.BUTTON_POSITIVE );
|
||||||
boolean enabled = startGroup == -1;
|
boolean enabled = fSrcGroup == -1;
|
||||||
if ( !enabled ) {
|
if ( !enabled ) {
|
||||||
long newGroup = self.m_adapter.getGroupIDFor( item );
|
long newGroup = self.m_adapter.getGroupIDFor( item );
|
||||||
enabled = newGroup != startGroup;
|
enabled = newGroup != fSrcGroup;
|
||||||
}
|
}
|
||||||
btn.setEnabled( enabled );
|
btn.setEnabled( enabled );
|
||||||
}
|
}
|
||||||
|
@ -789,10 +798,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
GamesListDelegate self = curThis();
|
GamesListDelegate self = curThis();
|
||||||
Assert.assertTrue( -1 != selItem[0] );
|
Assert.assertTrue( -1 != selItem[0] );
|
||||||
long gid = self.m_adapter.getGroupIDFor( selItem[0] );
|
long gid = self.m_adapter.getGroupIDFor( selItem[0] );
|
||||||
for ( long rowid : self.m_rowids ) {
|
self.moveSelGamesTo( gid );
|
||||||
DBUtils.moveGame( self.m_activity, rowid, gid );
|
|
||||||
}
|
|
||||||
self.mkListAdapter();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
OnClickListener lstnr3 =
|
OnClickListener lstnr3 =
|
||||||
|
@ -804,7 +810,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
String[] groups = m_adapter.groupNames();
|
String[] groups = m_adapter.groupNames();
|
||||||
int curGroupPos = m_adapter.getGroupPosition( startGroup );
|
int curGroupPos = m_adapter.getGroupPosition( fSrcGroup );
|
||||||
dialog = makeAlertBuilder()
|
dialog = makeAlertBuilder()
|
||||||
.setTitle( R.string.change_group )
|
.setTitle( R.string.change_group )
|
||||||
.setSingleChoiceItems( groups, curGroupPos, lstnr )
|
.setSingleChoiceItems( groups, curGroupPos, lstnr )
|
||||||
|
@ -1036,7 +1042,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
{
|
{
|
||||||
// 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 );
|
||||||
outState.putBoolean( SAVE_NEXTSOLO, m_nextIsSolo );
|
outState.putBoolean( SAVE_NEXTSOLO, m_nextIsSolo );
|
||||||
|
@ -1052,7 +1057,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
{
|
{
|
||||||
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 = NetLaunchInfo.makeFrom( bundle );
|
m_netLaunchInfo = NetLaunchInfo.makeFrom( bundle );
|
||||||
m_missingDictName = bundle.getString( SAVE_DICTNAMES );
|
m_missingDictName = bundle.getString( SAVE_DICTNAMES );
|
||||||
|
@ -1072,6 +1076,22 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void moveSelGamesTo( long gid )
|
||||||
|
{
|
||||||
|
for ( long rowid : m_selGames ) {
|
||||||
|
DBUtils.moveGame( m_activity, rowid, gid );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invalidate if there could have been change
|
||||||
|
if ( ! DBUtils.getGroups( m_activity ).get( gid ).m_expanded ) {
|
||||||
|
m_selGames.clear();
|
||||||
|
invalidateOptionsMenuIf();
|
||||||
|
setTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
mkListAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
public void invalidateOptionsMenuIf()
|
public void invalidateOptionsMenuIf()
|
||||||
{
|
{
|
||||||
super.invalidateOptionsMenuIf();
|
super.invalidateOptionsMenuIf();
|
||||||
|
@ -1797,7 +1817,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.games_game_move:
|
case R.id.games_game_move:
|
||||||
m_rowids = selRowIDs;
|
|
||||||
showDialog( DlgID.CHANGE_GROUP );
|
showDialog( DlgID.CHANGE_GROUP );
|
||||||
break;
|
break;
|
||||||
case R.id.games_game_new_from:
|
case R.id.games_game_new_from:
|
||||||
|
|
Loading…
Add table
Reference in a new issue