move interfaces out of GameListAdapter and into own file; should be no

change beyond renaming.
This commit is contained in:
Eric House 2013-10-30 06:29:31 -07:00
parent 1d7a443c8d
commit dbf76287a8
5 changed files with 55 additions and 30 deletions

View file

@ -45,24 +45,12 @@ public class GameListAdapter implements ExpandableListAdapter {
private ExpandableListView m_list;
private int m_fieldID;
private Handler m_handler;
private LoadItemCB m_cb;
private SelectableItem m_cb;
private long[] m_positions;
public interface LoadItemCB {
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 {
public void longClicked();
}
public GameListAdapter( Context context, ExpandableListView list,
Handler handler, LoadItemCB cb, long[] positions,
String fieldName )
Handler handler, SelectableItem cb,
long[] positions, String fieldName )
{
m_context = context;
m_list = list;

View file

@ -28,17 +28,17 @@ import android.view.View;
import org.eehouse.android.xw4.DBUtils.GameGroupInfo;
public class GameListGroup extends ExpiringTextView
implements GameListAdapter.ClickHandler
implements SelectableItem.LongClickHandler
{
private int m_groupPosition;
private long m_groupID;
private boolean m_expanded;
private GameListAdapter.LoadItemCB m_cb;
private SelectableItem m_cb;
public static GameListGroup makeForPosition( Context context,
int groupPosition,
long groupID,
GameListAdapter.LoadItemCB cb )
SelectableItem cb )
{
GameListGroup result =
(GameListGroup)Utils.inflate( context, R.layout.game_list_group );

View file

@ -43,7 +43,7 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.GameSummary;
public class GameListItem extends LinearLayout
implements View.OnClickListener, GameListAdapter.ClickHandler {
implements View.OnClickListener, SelectableItem.LongClickHandler {
private static HashSet<Long> s_invalRows = new HashSet<Long>();
@ -57,7 +57,7 @@ public class GameListItem extends LinearLayout
private ImageButton m_expandButton;
private Handler m_handler;
private GameSummary m_summary;
private GameListAdapter.LoadItemCB m_cb;
private SelectableItem m_cb;
private int m_fieldID;
private int m_loadingCount;
private int m_groupPosition;
@ -87,7 +87,7 @@ public class GameListItem extends LinearLayout
}
private void init( Handler handler, long rowid, int groupPosition,
int fieldID, GameListAdapter.LoadItemCB cb )
int fieldID, SelectableItem cb )
{
m_handler = handler;
m_rowid = rowid;
@ -343,7 +343,7 @@ public class GameListItem extends LinearLayout
public static GameListItem makeForRow( Context context, long rowid,
Handler handler, int groupPosition,
int fieldID,
GameListAdapter.LoadItemCB cb )
SelectableItem cb )
{
GameListItem result =
(GameListItem)Utils.inflate( context, R.layout.game_list_item );

View file

@ -58,8 +58,7 @@ import org.eehouse.android.xw4.jni.*;
public class GamesList extends XWExpandableListActivity
implements OnItemLongClickListener,
DBUtils.DBChangeListener,
GameListAdapter.LoadItemCB,
DBUtils.DBChangeListener, SelectableItem,
DictImportActivity.DownloadFinishedListener {
private static final int WARN_NODICT = DlgDelegate.DIALOG_LAST + 1;
@ -473,9 +472,9 @@ public class GamesList extends XWExpandableListActivity
// OnItemLongClickListener interface
public boolean onItemLongClick( AdapterView<?> parent, View view,
int position, long id ) {
boolean success = view instanceof GameListAdapter.ClickHandler;
boolean success = view instanceof SelectableItem.LongClickHandler;
if ( success ) {
((GameListAdapter.ClickHandler)view).longClicked();
((SelectableItem.LongClickHandler)view).longClicked();
}
return success;
}
@ -494,8 +493,8 @@ public class GamesList extends XWExpandableListActivity
} );
}
// GameListAdapter.LoadItemCB interface
public void itemClicked( GameListAdapter.ClickHandler clicked,
// SelectableItem interface
public void itemClicked( SelectableItem.LongClickHandler clicked,
GameSummary summary )
{
// We need a way to let the user get back to the basic-config
@ -512,7 +511,7 @@ public class GamesList extends XWExpandableListActivity
}
}
public void itemToggled( GameListAdapter.ClickHandler toggled,
public void itemToggled( SelectableItem.LongClickHandler toggled,
boolean selected )
{
if ( toggled instanceof GameListItem ) {
@ -536,7 +535,7 @@ public class GamesList extends XWExpandableListActivity
setTitleBar();
}
public boolean getSelected( GameListAdapter.ClickHandler obj )
public boolean getSelected( SelectableItem.LongClickHandler obj )
{
boolean selected;
if ( obj instanceof GameListItem ) {

View file

@ -0,0 +1,38 @@
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
/*
* Copyright 2009-2013 by Eric House (xwords@eehouse.org). All
* rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.eehouse.android.xw4;
import org.eehouse.android.xw4.jni.GameSummary;
// Interfaces used for (list) items that are selectable via
// long-tapping.
public interface SelectableItem {
public interface LongClickHandler {
public void longClicked();
}
public void itemClicked( LongClickHandler clicked, GameSummary summary );
public void itemToggled( LongClickHandler toggled, boolean selected );
public boolean getSelected( LongClickHandler obj );
}