make static GamesListItem method responsible for providing new instances.

This commit is contained in:
Eric House 2012-12-28 20:00:46 -08:00
parent 21e572acfc
commit 4d07046a99
2 changed files with 16 additions and 10 deletions

View file

@ -22,15 +22,12 @@ package org.eehouse.android.xw4;
import android.content.Context;
import android.database.DataSetObserver;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.TextView;
import java.util.HashMap; // class is not synchronized
import java.util.Iterator;
import java.util.Set;
import junit.framework.Assert;
@ -42,7 +39,6 @@ import org.eehouse.android.xw4.DBUtils.GameGroupInfo;
public class GameListAdapter implements ExpandableListAdapter {
private Context m_context;
private ExpandableListView m_list;
private LayoutInflater m_factory;
private int m_fieldID;
private Handler m_handler;
private LoadItemCB m_cb;
@ -61,7 +57,6 @@ public class GameListAdapter implements ExpandableListAdapter {
m_handler = handler;
m_cb = cb;
m_positions = positions;
m_factory = LayoutInflater.from( context );
m_fieldID = fieldToID( fieldName );
}
@ -193,9 +188,9 @@ public class GameListAdapter implements ExpandableListAdapter {
private View getChildView( int groupPosition, int childPosition )
{
long rowid = getRowIDFor( groupPosition, childPosition );
GameListItem result = (GameListItem)
m_factory.inflate( R.layout.game_list_item, null );
result.init( m_handler, rowid, groupPosition, m_fieldID, m_cb );
GameListItem result =
GameListItem.makeForRow( m_context, rowid, m_handler,
groupPosition, m_fieldID, m_cb );
return result;
}

View file

@ -69,8 +69,8 @@ public class GameListItem extends LinearLayout
m_loadingCount = 0;
}
public void init( Handler handler, long rowid, int groupPosition,
int fieldID, GameListAdapter.LoadItemCB cb )
private void init( Handler handler, long rowid, int groupPosition,
int fieldID, GameListAdapter.LoadItemCB cb )
{
m_handler = handler;
m_rowid = rowid;
@ -304,6 +304,17 @@ public class GameListItem extends LinearLayout
}
} // class LoadItemTask
public static GameListItem makeForRow( Context context, long rowid,
Handler handler, int groupPosition,
int fieldID,
GameListAdapter.LoadItemCB cb )
{
GameListItem result =
(GameListItem)Utils.inflate( context, R.layout.game_list_item );
result.init( handler, rowid, groupPosition, fieldID, cb );
return result;
}
public static void inval( long rowid )
{
synchronized( s_invalRows ) {