use static HashMap to track what language views are open and closed.

As long as I'm not reloaded user choice will be preserved.  Good
enough.
This commit is contained in:
Andy2 2011-09-12 19:00:13 -07:00
parent 72d769910b
commit 99498a8568

View file

@ -23,14 +23,12 @@ package org.eehouse.android.xw4;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ListActivity;
import android.app.ExpandableListActivity;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Button;
import android.widget.TextView;
import android.widget.AdapterView;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -49,6 +47,7 @@ import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.Toast;
import android.preference.PreferenceManager;
import android.net.Uri;
import java.util.HashMap;
import junit.framework.Assert;
import org.eehouse.android.xw4.DictUtils.DictAndLoc;
@ -70,6 +69,9 @@ public class DictsActivity extends ExpandableListActivity
private static final String MOVEFROMLOC = "movefromloc";
private static final String MOVETOLOC = "movetoloc";
private static HashMap<String,Boolean> s_openStates =
new HashMap<String,Boolean>();
// For new callback alternative
private static final int DELETE_DICT_ACTION = 1;
@ -207,8 +209,13 @@ public class DictsActivity extends ExpandableListActivity
public boolean isChildSelectable( int groupPosition,
int childPosition ) { return true; }
public boolean isEmpty() { return false; }
public void onGroupCollapsed(int groupPosition){}
public void onGroupExpanded(int groupPosition){}
public void onGroupCollapsed(int groupPosition)
{
s_openStates.put( m_langs[groupPosition], false );
}
public void onGroupExpanded(int groupPosition){
s_openStates.put( m_langs[groupPosition], true );
}
public void registerDataSetObserver( DataSetObserver obs ){}
public void unregisterDataSetObserver( DataSetObserver obs ){}
@ -632,9 +639,16 @@ public class DictsActivity extends ExpandableListActivity
private void expandGroups()
{
for ( int ii = 0; ii < m_langs.length; ++ii ) {
boolean open = true;
String lang = m_langs[ii];
if ( s_openStates.containsKey( lang ) ) {
open = s_openStates.get( lang );
}
if ( open ) {
m_expView.expandGroup( ii );
}
}
}
private static Intent mkDownloadIntent( Context context,
int lang, String dict )