From 3a1b39f827ed636d63f3f9f5215ea34e92fb5ae7 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 18 Dec 2012 06:36:30 -0800 Subject: [PATCH] more of the (conflicted) merge from android_branch. These may be changes I need to make to get what git produced to compile and so not what it included in the previous commit. --- .../src/org/eehouse/android/xw4/DBUtils.java | 17 ------- .../eehouse/android/xw4/GameListAdapter.java | 44 +++++++++++++------ .../org/eehouse/android/xw4/GamesList.java | 4 +- .../android/xw4/XWExpandableListActivity.java | 2 +- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java index a9495ef3b..40456f35a 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -1401,23 +1401,6 @@ public class DBUtils { } } - private static void updateRow( Context context, String table, - long rowid, ContentValues values ) - { - initDB( context ); - synchronized( s_dbHelper ) { - SQLiteDatabase db = s_dbHelper.getWritableDatabase(); - - String selection = String.format( ROW_ID_FMT, rowid ); - - int result = db.update( table, values, selection, null ); - db.close(); - if ( 0 == result ) { - DbgUtils.logf( "updateRow failed" ); - } - } - } - private static void notifyListeners( long rowid, boolean countChanged ) { synchronized( s_listeners ) { 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 320594293..d3cbb73f9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -202,7 +202,10 @@ public class GameListAdapter implements ExpandableListAdapter { private View getChildView( int groupPosition, int childPosition ) { long rowid = getRowIDFor( groupPosition, childPosition ); - return getItem( rowid ); + GameListItem result = (GameListItem) + m_factory.inflate( R.layout.game_list_item, null ); + result.init( m_handler, rowid, m_fieldID, m_cb ); + return result; } public View getGroupView( int groupPosition, boolean isExpanded, @@ -372,9 +375,16 @@ public class GameListAdapter implements ExpandableListAdapter { private GameListItem getItemFor( long rowid ) { GameListItem result = null; - int position = positionFor( rowid ); - if ( 0 <= position ) { - result = (GameListItem)m_list.getChildAt( position ); + int count = m_list.getChildCount(); + for ( int ii = 0; ii < count; ++ii ) { + View view = m_list.getChildAt( ii ); + if ( view instanceof GameListItem ) { + GameListItem tryme = (GameListItem)view; + if ( tryme.getRowID() == rowid ) { + result = tryme; + break; + } + } } return result; } @@ -397,16 +407,22 @@ public class GameListAdapter implements ExpandableListAdapter { return result; } - private int positionFor( long rowid ) + // private int positionFor( long rowid ) + // { + // int position = -1; + // long[] rowids = DBUtils.gamesList( m_context ); + // for ( int ii = 0; ii < rowids.length; ++ii ) { + // if ( rowids[ii] == rowid ) { + // position = ii; + // break; + // } + // } + // return position; + // } + + private HashMap gameInfo() { - int position = -1; - long[] rowids = DBUtils.gamesList( m_context ); - for ( int ii = 0; ii < rowids.length; ++ii ) { - if ( rowids[ii] == rowid ) { - position = ii; - break; - } - } - return position; + return DBUtils.getGroups( m_context ); } + } 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 53e062129..602a05bd2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -347,8 +347,8 @@ public class GamesList extends XWExpandableListActivity }); String field = CommonPrefs.getSummaryField( this ); - m_adapter = new GameListAdapter( this, getListView(), new Handler(), - this, field ); + m_adapter = new GameListAdapter( this, getExpandableListView(), + new Handler(), this, field ); setListAdapter( m_adapter ); NetUtils.informOfDeaths( this ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java index 6dea66923..b20e29c87 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWExpandableListActivity.java @@ -29,7 +29,7 @@ import junit.framework.Assert; public class XWExpandableListActivity extends ExpandableListActivity - implements DlgDelegate.DlgClickNotify, MultiService.BTEventListener { + implements DlgDelegate.DlgClickNotify, MultiService.MultiEventListener { private DlgDelegate m_delegate;