mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
recycle views for games list elements too
This commit is contained in:
parent
f3f5bf10a5
commit
e674ae4a3c
4 changed files with 23 additions and 14 deletions
|
@ -48,14 +48,20 @@ public class GameListGroup extends ExpiringLinearLayout
|
|||
private ImageButton m_expandButton;
|
||||
|
||||
public static GameListGroup makeForPosition( Context context,
|
||||
View convertView,
|
||||
long groupID,
|
||||
int nGames,
|
||||
boolean expanded,
|
||||
SelectableItem cb,
|
||||
GroupStateListener gcb )
|
||||
{
|
||||
GameListGroup result = (GameListGroup)
|
||||
LocUtils.inflate( context, R.layout.game_list_group );
|
||||
GameListGroup result;
|
||||
if ( null != convertView && convertView instanceof GameListGroup ) {
|
||||
result = (GameListGroup)convertView;
|
||||
} else {
|
||||
result = (GameListGroup)
|
||||
LocUtils.inflate( context, R.layout.game_list_group );
|
||||
}
|
||||
result.m_cb = cb;
|
||||
result.m_gcb = gcb;
|
||||
result.m_groupID = groupID;
|
||||
|
|
|
@ -364,12 +364,17 @@ public class GameListItem extends LinearLayout
|
|||
}
|
||||
} // class LoadItemTask
|
||||
|
||||
public static GameListItem makeForRow( Context context, long rowid,
|
||||
Handler handler, int fieldID,
|
||||
SelectableItem cb )
|
||||
public static GameListItem makeForRow( Context context, View convertView,
|
||||
long rowid, Handler handler,
|
||||
int fieldID, SelectableItem cb )
|
||||
{
|
||||
GameListItem result =
|
||||
(GameListItem)LocUtils.inflate( context, R.layout.game_list_item );
|
||||
GameListItem result;
|
||||
if ( null != convertView && convertView instanceof GameListItem ) {
|
||||
result = (GameListItem)convertView;
|
||||
} else {
|
||||
result = (GameListItem)LocUtils.inflate( context,
|
||||
R.layout.game_list_item );
|
||||
}
|
||||
result.init( handler, rowid, fieldID, cb );
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -131,8 +131,9 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
GameGroupInfo ggi = DBUtils.getGroups( m_activity )
|
||||
.get( rec.m_groupID );
|
||||
GameListGroup group =
|
||||
GameListGroup.makeForPosition( m_activity, rec.m_groupID,
|
||||
ggi.m_count, ggi.m_expanded,
|
||||
GameListGroup.makeForPosition( m_activity, convertView,
|
||||
rec.m_groupID, ggi.m_count,
|
||||
ggi.m_expanded,
|
||||
GamesListDelegate.this,
|
||||
GamesListDelegate.this );
|
||||
if ( !ggi.m_expanded ) {
|
||||
|
@ -148,7 +149,8 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
} else if ( dataObj instanceof GameRec ) {
|
||||
GameRec rec = (GameRec)dataObj;
|
||||
GameListItem item =
|
||||
GameListItem.makeForRow( m_activity, rec.m_rowID, m_handler,
|
||||
GameListItem.makeForRow( m_activity, convertView,
|
||||
rec.m_rowID, m_handler,
|
||||
m_fieldID, GamesListDelegate.this );
|
||||
item.setSelected( m_selGames.contains( rec.m_rowID ) );
|
||||
result = item;
|
||||
|
|
|
@ -82,10 +82,6 @@ abstract class XWExpListAdapter extends XWListAdapter {
|
|||
@Override
|
||||
public View getView( int position, View convertView, ViewGroup parent )
|
||||
{
|
||||
if ( null != convertView ) {
|
||||
DbgUtils.logf( "getView: missing opportunity to reuse view %H",
|
||||
convertView );
|
||||
}
|
||||
View result = getView( m_listObjs[position], convertView );
|
||||
// DbgUtils.logf( "getView(position=%d) => %H (%s)", position, result,
|
||||
// result.getClass().getName() );
|
||||
|
|
Loading…
Reference in a new issue