From 75e54fa7270f29562b7a842984272444d864a9c3 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 12 Jul 2014 11:04:41 -0700 Subject: [PATCH] don't reuse game list group if it's had its background changed since that can't be undone (yet) --- .../eehouse/android/xw4/ExpiringLinearLayout.java | 5 +++++ .../src/org/eehouse/android/xw4/GameListGroup.java | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ExpiringLinearLayout.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ExpiringLinearLayout.java index 4350f474a..97ff4cfce 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/ExpiringLinearLayout.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/ExpiringLinearLayout.java @@ -44,6 +44,11 @@ public class ExpiringLinearLayout extends LinearLayout { m_delegate.configure( haveTurn, haveTurnLocal, startSecs ); } + public boolean hasDelegate() + { + return null != m_delegate; + } + @Override // not called unless setWillNotDraw( false ) called protected void onDraw( Canvas canvas ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java index b29e9e62b..1442f70f0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListGroup.java @@ -55,10 +55,18 @@ public class GameListGroup extends ExpiringLinearLayout SelectableItem cb, GroupStateListener gcb ) { - GameListGroup result; + GameListGroup result = null; if ( null != convertView && convertView instanceof GameListGroup ) { result = (GameListGroup)convertView; - } else { + + // Hack: once an ExpiringLinearLayout has a background it's not + // set up to be reused without one. Until that's fixed, don't + // reuse in that case. + if ( result.hasDelegate() ) { + result = null; + } + } + if ( null == result ) { result = (GameListGroup) LocUtils.inflate( context, R.layout.game_list_group ); }