when KP is deleted, remove record of its being expanded

I'm tired of having a record recreated and showing up expanded first
thing. Better to save less garbage.
This commit is contained in:
Eric House 2021-03-20 08:49:41 -07:00
parent 88e76af7ab
commit e1712f4560

View file

@ -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<String> children = mChildren.keySet();
for ( Iterator<String> 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 );