From b61f1fbac9a0219e956722dbdbfd9951de4b9a5c Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 9 Apr 2014 05:52:36 -0700 Subject: [PATCH] fix crash adding first game to newly installed app by counting games and groups the same way getView determines if they exist. --- .../src/org/eehouse/android/xw4/GameListAdapter.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 347471323..b117dced5 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -68,8 +68,15 @@ public class GameListAdapter extends XWListAdapter @Override public int getCount() { - return DBUtils.getGroups( m_context ).size() - + DBUtils.countVisibleGames( m_context ); + HashMap groups = DBUtils.getGroups( m_context ); + int count = groups.size(); + for ( GameGroupInfo ggi : groups.values() ) { + if ( ggi.m_expanded ) { + count += ggi.m_count; + } + } + // DbgUtils.logf( "GameListAdapter.getCount() => %d", count ); + return count; } @Override