mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
Fix so when child is invalidated its group/parent also is. Now when
an invisible child gets a network game message that changes its expiry rendering and it's the one the group is showing, the group will follow.
This commit is contained in:
parent
3436a71d65
commit
e8c3c304ab
6 changed files with 119 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<org.eehouse.android.xw4.ExpiringTextView
|
||||
<org.eehouse.android.xw4.GameListGroup
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/game_name"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -8,4 +8,6 @@
|
|||
android:gravity="right"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:paddingTop="3dp"
|
||||
android:paddingBottom="3dp"
|
||||
/>
|
||||
|
|
|
@ -320,6 +320,7 @@ public class DBUtils {
|
|||
}
|
||||
db.close();
|
||||
notifyListeners( rowid, false );
|
||||
invalGroupsCache();
|
||||
}
|
||||
} // saveSummary
|
||||
|
||||
|
@ -728,6 +729,7 @@ public class DBUtils {
|
|||
if ( -1 != rowid ) { // Means new game?
|
||||
notifyListeners( rowid, false );
|
||||
}
|
||||
invalGroupsCache();
|
||||
return rowid;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,17 @@ class ExpiringTextView extends TextView {
|
|||
if ( null == m_delegate ) {
|
||||
m_delegate = new ExpiringDelegate( m_context, this, handler );
|
||||
}
|
||||
m_delegate.configure( haveTurn, haveTurnLocal, startSecs );
|
||||
setPct( haveTurn, haveTurnLocal, startSecs );
|
||||
}
|
||||
|
||||
public void setPct( boolean haveTurn, boolean haveTurnLocal,
|
||||
long startSecs )
|
||||
{
|
||||
if ( null != m_delegate ) {
|
||||
m_delegate.configure( haveTurn, haveTurnLocal, startSecs );
|
||||
} else {
|
||||
DbgUtils.logf( "m_delegate null; skipping" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -179,18 +179,19 @@ public class GameListAdapter implements ExpandableListAdapter {
|
|||
long rowid = getRowIDFor( groupPosition, childPosition );
|
||||
GameListItem result = (GameListItem)
|
||||
m_factory.inflate( R.layout.game_list_item, null );
|
||||
result.init( m_handler, rowid, m_fieldID, m_cb );
|
||||
result.init( m_handler, rowid, groupPosition, m_fieldID, m_cb );
|
||||
return result;
|
||||
}
|
||||
|
||||
public View getGroupView( int groupPosition, boolean isExpanded,
|
||||
View convertView, ViewGroup parent )
|
||||
{
|
||||
if ( null != convertView ) {
|
||||
DbgUtils.logf( "getGroupView gave non-null convertView" );
|
||||
}
|
||||
ExpiringTextView view = (ExpiringTextView)
|
||||
// if ( null != convertView ) {
|
||||
// DbgUtils.logf( "getGroupView gave non-null convertView" );
|
||||
// }
|
||||
GameListGroup view = (GameListGroup)
|
||||
Utils.inflate(m_context, R.layout.game_list_group );
|
||||
view.setGroupPosition( groupPosition );
|
||||
|
||||
String name = groupNames()[groupPosition];
|
||||
|
||||
|
@ -248,19 +249,26 @@ public class GameListAdapter implements ExpandableListAdapter {
|
|||
|
||||
public void inval( long rowid )
|
||||
{
|
||||
GameListItem child = getItemFor( rowid );
|
||||
GameListItem child = getGameItemFor( rowid );
|
||||
int groupPosition;
|
||||
if ( null != child && child.getRowID() == rowid ) {
|
||||
child.forceReload();
|
||||
|
||||
groupPosition = child.getGroupPosition();
|
||||
} else {
|
||||
DbgUtils.logf( "no child for rowid %d", rowid );
|
||||
GameListItem.inval( rowid );
|
||||
m_list.invalidate();
|
||||
|
||||
long groupID = DBUtils.getGroupForGame( m_context, rowid );
|
||||
groupPosition = getGroupPosition( groupID );
|
||||
}
|
||||
reloadGroup( groupPosition );
|
||||
}
|
||||
|
||||
public void invalName( long rowid )
|
||||
{
|
||||
GameListItem item = getItemFor( rowid );
|
||||
GameListItem item = getGameItemFor( rowid );
|
||||
if ( null != item ) {
|
||||
item.invalName();
|
||||
}
|
||||
|
@ -320,7 +328,13 @@ public class GameListAdapter implements ExpandableListAdapter {
|
|||
return changed;
|
||||
}
|
||||
|
||||
private GameListItem getItemFor( long rowid )
|
||||
private GameGroupInfo getInfoForGroup( int groupPosition )
|
||||
{
|
||||
String name = groupNames()[groupPosition];
|
||||
return gameInfo().get( name );
|
||||
}
|
||||
|
||||
private GameListItem getGameItemFor( long rowid )
|
||||
{
|
||||
GameListItem result = null;
|
||||
int count = m_list.getChildCount();
|
||||
|
@ -337,6 +351,23 @@ public class GameListAdapter implements ExpandableListAdapter {
|
|||
return result;
|
||||
}
|
||||
|
||||
private GameListGroup getGroupItemFor( int groupPosition )
|
||||
{
|
||||
GameListGroup result = null;
|
||||
int count = m_list.getChildCount();
|
||||
for ( int ii = 0; ii < count; ++ii ) {
|
||||
View view = m_list.getChildAt( ii );
|
||||
if ( view instanceof GameListGroup ) {
|
||||
GameListGroup tryme = (GameListGroup)view;
|
||||
if ( tryme.getGroupPosition() == groupPosition ) {
|
||||
result = tryme;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int fieldToID( String fieldName )
|
||||
{
|
||||
int[] ids = {
|
||||
|
@ -355,6 +386,15 @@ public class GameListAdapter implements ExpandableListAdapter {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void reloadGroup( int groupPosition )
|
||||
{
|
||||
GameListGroup group = getGroupItemFor( groupPosition );
|
||||
if ( null != group ) {
|
||||
GameGroupInfo ggi = getInfoForGroup( groupPosition );
|
||||
group.setPct( ggi.m_hasTurn, ggi.m_turnLocal, ggi.m_lastMoveTime );
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<String,GameGroupInfo> gameInfo()
|
||||
{
|
||||
return DBUtils.getGroups( m_context );
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2012 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 android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import org.eehouse.android.xw4.DBUtils.GameGroupInfo;
|
||||
|
||||
public class GameListGroup extends ExpiringTextView {
|
||||
private int m_groupPosition;
|
||||
|
||||
public GameListGroup( Context cx, AttributeSet as )
|
||||
{
|
||||
super( cx, as );
|
||||
}
|
||||
|
||||
public void setGroupPosition( int groupPosition )
|
||||
{
|
||||
m_groupPosition = groupPosition;
|
||||
}
|
||||
|
||||
public int getGroupPosition()
|
||||
{
|
||||
return m_groupPosition;
|
||||
}
|
||||
}
|
|
@ -57,6 +57,7 @@ public class GameListItem extends LinearLayout
|
|||
private GameListAdapter.LoadItemCB m_cb;
|
||||
private int m_fieldID;
|
||||
private int m_loadingCount;
|
||||
private int m_groupPosition;
|
||||
|
||||
public GameListItem( Context cx, AttributeSet as )
|
||||
{
|
||||
|
@ -68,11 +69,12 @@ public class GameListItem extends LinearLayout
|
|||
m_loadingCount = 0;
|
||||
}
|
||||
|
||||
public void init( Handler handler, long rowid, int fieldID,
|
||||
GameListAdapter.LoadItemCB cb )
|
||||
public void init( Handler handler, long rowid, int groupPosition,
|
||||
int fieldID, GameListAdapter.LoadItemCB cb )
|
||||
{
|
||||
m_handler = handler;
|
||||
m_rowid = rowid;
|
||||
m_groupPosition = groupPosition;
|
||||
m_fieldID = fieldID;
|
||||
m_cb = cb;
|
||||
|
||||
|
@ -128,6 +130,11 @@ public class GameListItem extends LinearLayout
|
|||
return m_rowid;
|
||||
}
|
||||
|
||||
public int getGroupPosition()
|
||||
{
|
||||
return m_groupPosition;
|
||||
}
|
||||
|
||||
// View.OnClickListener interface
|
||||
public void onClick( View view ) {
|
||||
m_expanded = !m_expanded;
|
||||
|
|
Loading…
Reference in a new issue