diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/KnownPlayersDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/KnownPlayersDelegate.java index 44e5e5afa..f4f717b94 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/KnownPlayersDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/KnownPlayersDelegate.java @@ -36,8 +36,10 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import org.eehouse.android.xw4.DlgDelegate.Action; import org.eehouse.android.xw4.ExpandImageButton.ExpandChangeListener; @@ -145,6 +147,7 @@ public class KnownPlayersDelegate extends DelegateBase { } } addInOrder(); + pruneExpanded(); } } @@ -158,6 +161,22 @@ public class KnownPlayersDelegate extends DelegateBase { } } + private void pruneExpanded() + { + boolean doSave = false; + Set children = mChildren.keySet(); + for ( Iterator iter = mExpSet.iterator(); iter.hasNext(); ) { + String child = iter.next(); + if ( !children.contains(child) ) { + iter.remove(); + doSave = true; + } + } + if ( doSave ) { + saveExpanded(); + } + } + private void setName( ViewGroup item, String name ) { TextView tv = (TextView)item.findViewById( R.id.player_name );