mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
remember which KnownPlayer entries are expanded
This commit is contained in:
parent
4aaee07369
commit
91d306270d
1 changed files with 33 additions and 1 deletions
|
@ -35,6 +35,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -47,10 +48,12 @@ import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class KnownPlayersDelegate extends DelegateBase {
|
public class KnownPlayersDelegate extends DelegateBase {
|
||||||
private static final String TAG = KnownPlayersDelegate.class.getSimpleName();
|
private static final String TAG = KnownPlayersDelegate.class.getSimpleName();
|
||||||
|
private static final String KEY_EXPSET = TAG + "/expset";
|
||||||
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private ViewGroup mList;
|
private ViewGroup mList;
|
||||||
private Map<String, ViewGroup> mChildren;
|
private Map<String, ViewGroup> mChildren;
|
||||||
|
private HashSet<String> mExpSet;
|
||||||
|
|
||||||
protected KnownPlayersDelegate( Delegator delegator, Bundle sis )
|
protected KnownPlayersDelegate( Delegator delegator, Bundle sis )
|
||||||
{
|
{
|
||||||
|
@ -62,6 +65,7 @@ public class KnownPlayersDelegate extends DelegateBase {
|
||||||
protected void init( Bundle sis )
|
protected void init( Bundle sis )
|
||||||
{
|
{
|
||||||
mList = (ViewGroup)findViewById( R.id.players_list );
|
mList = (ViewGroup)findViewById( R.id.players_list );
|
||||||
|
loadExpanded();
|
||||||
populateList();
|
populateList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +178,7 @@ public class KnownPlayersDelegate extends DelegateBase {
|
||||||
addInOrder();
|
addInOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ViewGroup makePlayerElem( String player )
|
private ViewGroup makePlayerElem( final String player )
|
||||||
{
|
{
|
||||||
ViewGroup view = null;
|
ViewGroup view = null;
|
||||||
int lastMod[] = {0};
|
int lastMod[] = {0};
|
||||||
|
@ -236,8 +240,15 @@ public class KnownPlayersDelegate extends DelegateBase {
|
||||||
{
|
{
|
||||||
item.findViewById(R.id.hidden_part)
|
item.findViewById(R.id.hidden_part)
|
||||||
.setVisibility(nowExpanded?View.VISIBLE:View.GONE);
|
.setVisibility(nowExpanded?View.VISIBLE:View.GONE);
|
||||||
|
if ( nowExpanded ) {
|
||||||
|
mExpSet.add( player );
|
||||||
|
} else {
|
||||||
|
mExpSet.remove( player );
|
||||||
|
}
|
||||||
|
saveExpanded();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
eib.setExpanded( mExpSet.contains(player) );
|
||||||
|
|
||||||
item.findViewById( R.id.player_line )
|
item.findViewById( R.id.player_line )
|
||||||
.setOnClickListener( new View.OnClickListener() {
|
.setOnClickListener( new View.OnClickListener() {
|
||||||
|
@ -273,6 +284,27 @@ public class KnownPlayersDelegate extends DelegateBase {
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadExpanded()
|
||||||
|
{
|
||||||
|
HashSet<String> expSet;
|
||||||
|
try {
|
||||||
|
expSet = (HashSet<String>)DBUtils.getSerializableFor( mActivity, KEY_EXPSET );
|
||||||
|
} catch ( Exception ex ) {
|
||||||
|
Log.ex( TAG, ex );
|
||||||
|
expSet = null;
|
||||||
|
}
|
||||||
|
if ( null == expSet ) {
|
||||||
|
expSet = new HashSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
mExpSet = expSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveExpanded()
|
||||||
|
{
|
||||||
|
DBUtils.setSerializableFor( mActivity, KEY_EXPSET, mExpSet );
|
||||||
|
}
|
||||||
|
|
||||||
public static void launchOrAlert( Delegator delegator,
|
public static void launchOrAlert( Delegator delegator,
|
||||||
DlgDelegate.HasDlgDelegate dlg )
|
DlgDelegate.HasDlgDelegate dlg )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue