unselect any game moved into a closed group

Fixes GameOver game moved via "archive" checkbox remaining selected
This commit is contained in:
Eric House 2019-02-12 18:14:57 -08:00
parent b5ff337381
commit 0a5d74ab2f
3 changed files with 21 additions and 13 deletions

View file

@ -2656,14 +2656,8 @@ public class BoardDelegate extends DelegateBase
private void archiveGame( boolean closeAfter ) private void archiveGame( boolean closeAfter )
{ {
String archiveName = LocUtils long gid = DBUtils.getArchiveGroup( m_activity );
.getString( m_activity, R.string.group_name_archive ); DBUtils.moveGame( m_activity, m_rowid, gid );
long archiveGroupID = DBUtils.getGroup( m_activity, archiveName );
if ( DBUtils.GROUPID_UNSPEC == archiveGroupID ) {
archiveGroupID = DBUtils.addGroup( m_activity, archiveName );
}
DBUtils.moveGame( m_activity, m_rowid, archiveGroupID );
if ( closeAfter ) { if ( closeAfter ) {
waitCloseGame( false ); waitCloseGame( false );
finish(); finish();

View file

@ -1803,6 +1803,9 @@ public class DBUtils {
String archiveName = LocUtils String archiveName = LocUtils
.getString( context, R.string.group_name_archive ); .getString( context, R.string.group_name_archive );
long archiveGroup = getGroup( context, archiveName ); long archiveGroup = getGroup( context, archiveName );
if ( DBUtils.GROUPID_UNSPEC == archiveGroup ) {
archiveGroup = DBUtils.addGroup( context, archiveName );
}
return archiveGroup; return archiveGroup;
} }

View file

@ -1076,18 +1076,28 @@ public class GamesListDelegate extends ListDelegateBase
boolean destOpen = DBUtils.getGroups( m_activity ).get( gid ).m_expanded; boolean destOpen = DBUtils.getGroups( m_activity ).get( gid ).m_expanded;
for ( long rowid : games ) { for ( long rowid : games ) {
DBUtils.moveGame( m_activity, rowid, gid ); DBUtils.moveGame( m_activity, rowid, gid );
if ( !destOpen ) { unselIfHidden( rowid, gid );
m_mySIS.selGames.remove( rowid );
}
} }
}
// Invalidate if there could have been change private void unselIfHidden( long rowid, long gid )
if ( ! destOpen ) { {
boolean groupOpen = DBUtils.getGroups( m_activity )
.get( gid ).m_expanded;
if ( !groupOpen ) {
m_mySIS.selGames.remove( rowid );
// Invalidate if there could have been change
invalidateOptionsMenuIf(); invalidateOptionsMenuIf();
setTitle(); setTitle();
} }
} }
private void unselIfHidden( long rowid )
{
long gid = DBUtils.getGroupForGame( m_activity, rowid );
unselIfHidden( rowid, gid );
}
public void invalidateOptionsMenuIf() public void invalidateOptionsMenuIf()
{ {
super.invalidateOptionsMenuIf(); super.invalidateOptionsMenuIf();
@ -1158,6 +1168,7 @@ public class GamesListDelegate extends ListDelegateBase
setSelGame( rowid ); setSelGame( rowid );
break; break;
case GAME_MOVED: case GAME_MOVED:
unselIfHidden( rowid );
mkListAdapter(); mkListAdapter();
break; break;
default: default: