From 989f7524d6996a9ceaf2f6bf6679cd48c6dcf9f2 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 12 Feb 2019 18:14:57 -0800 Subject: [PATCH] unselect any game moved into a closed group Fixes GameOver game moved via "archive" checkbox remaining selected --- .../eehouse/android/xw4/BoardDelegate.java | 10 ++------- .../java/org/eehouse/android/xw4/DBUtils.java | 3 +++ .../android/xw4/GamesListDelegate.java | 21 ++++++++++++++----- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java index 85de8e13a..29f2ba68a 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BoardDelegate.java @@ -2656,14 +2656,8 @@ public class BoardDelegate extends DelegateBase private void archiveGame( boolean closeAfter ) { - String archiveName = LocUtils - .getString( m_activity, R.string.group_name_archive ); - 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 ); + long gid = DBUtils.getArchiveGroup( m_activity ); + DBUtils.moveGame( m_activity, m_rowid, gid ); if ( closeAfter ) { waitCloseGame( false ); finish(); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java index 4ae553acf..11fb075a0 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java @@ -1803,6 +1803,9 @@ public class DBUtils { String archiveName = LocUtils .getString( context, R.string.group_name_archive ); long archiveGroup = getGroup( context, archiveName ); + if ( DBUtils.GROUPID_UNSPEC == archiveGroup ) { + archiveGroup = DBUtils.addGroup( context, archiveName ); + } return archiveGroup; } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java index f5dd3a2bc..70b599af6 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java @@ -1076,18 +1076,28 @@ public class GamesListDelegate extends ListDelegateBase boolean destOpen = DBUtils.getGroups( m_activity ).get( gid ).m_expanded; for ( long rowid : games ) { DBUtils.moveGame( m_activity, rowid, gid ); - if ( !destOpen ) { - m_mySIS.selGames.remove( rowid ); - } + unselIfHidden( rowid, gid ); } + } - // Invalidate if there could have been change - if ( ! destOpen ) { + private void unselIfHidden( long rowid, long gid ) + { + 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(); setTitle(); } } + private void unselIfHidden( long rowid ) + { + long gid = DBUtils.getGroupForGame( m_activity, rowid ); + unselIfHidden( rowid, gid ); + } + public void invalidateOptionsMenuIf() { super.invalidateOptionsMenuIf(); @@ -1158,6 +1168,7 @@ public class GamesListDelegate extends ListDelegateBase setSelGame( rowid ); break; case GAME_MOVED: + unselIfHidden( rowid ); mkListAdapter(); break; default: