diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java index 78aaa2bc1..1db9ca408 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -49,9 +49,11 @@ public class GameListAdapter implements ExpandableListAdapter { private long[] m_positions; public interface LoadItemCB { - public void itemClicked( Object clicked, GameSummary summary ); - public void itemToggled( Object toggled, boolean selected ); - public boolean getSelected( long rowid ); + public void itemClicked( GameListAdapter.ClickHandler clicked, + GameSummary summary ); + public void itemToggled( GameListAdapter.ClickHandler toggled, + boolean selected ); + public boolean getSelected( GameListAdapter.ClickHandler obj ); } public interface ClickHandler { @@ -158,7 +160,7 @@ public class GameListAdapter implements ExpandableListAdapter { public void clearSelectedGames( long[] rowids ) { - deselectRows( rowids ); + deselectGames( rowids ); } public void clearSelectedGroups( HashSet groupIDs ) @@ -191,7 +193,7 @@ public class GameListAdapter implements ExpandableListAdapter { // for ( long rowid : rowids ) { // asSet.add( rowid ); // } - deselectRows( rowids ); + deselectGames( rowids ); } public void onGroupExpanded( int groupPosition ) @@ -257,6 +259,8 @@ public class GameListAdapter implements ExpandableListAdapter { groupNames()[groupPosition], nKids ); view.setText( name ); + view.setSelected( m_cb.getSelected( view ) ); + return view; } @@ -379,7 +383,7 @@ public class GameListAdapter implements ExpandableListAdapter { return gameInfo().get( getGroupPositions()[groupPosition] ); } - private void deselectRows( long[] rowids ) + private void deselectGames( long[] rowids ) { GameListItem[] items = new GameListItem[rowids.length]; getGameItemsFor( rowids, items ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java index 60b8038a9..79f6df793 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java @@ -335,7 +335,7 @@ public class GameListItem extends LinearLayout } } - if ( m_cb.getSelected( m_rowid ) && m_selected ) { + if ( m_cb.getSelected( GameListItem.this ) && m_selected ) { toggleSelected(); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index d19969956..46cf12fad 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -493,7 +493,8 @@ public class GamesList extends XWExpandableListActivity } // GameListAdapter.LoadItemCB interface - public void itemClicked( Object clicked, GameSummary summary ) + public void itemClicked( GameListAdapter.ClickHandler clicked, + GameSummary summary ) { // We need a way to let the user get back to the basic-config // dialog in case it was dismissed. That way it to check for @@ -509,7 +510,8 @@ public class GamesList extends XWExpandableListActivity } } - public void itemToggled( Object toggled, boolean selected ) + public void itemToggled( GameListAdapter.ClickHandler toggled, + boolean selected ) { if ( toggled instanceof GameListItem ) { long rowid = ((GameListItem)toggled).getRowID(); @@ -532,9 +534,20 @@ public class GamesList extends XWExpandableListActivity setTitleBar(); } - public boolean getSelected( long rowid ) + public boolean getSelected( GameListAdapter.ClickHandler obj ) { - return m_selGames.contains( rowid ); + boolean selected; + if ( obj instanceof GameListItem ) { + long rowid = ((GameListItem)obj).getRowID(); + selected = m_selGames.contains( rowid ); + } else if ( obj instanceof GameListGroup ) { + long groupID = ((GameListGroup)obj).getGroupID(); + selected = m_selGroupIDs.contains( groupID ); + } else { + Assert.fail(); + selected = false; + } + return selected; } // BTService.MultiEventListener interface