diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java index a00e1fb6d..2f06ac41e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java @@ -85,6 +85,7 @@ public class DictsDelegate extends ListDelegateBase private ListActivity m_activity; private Set m_closedLangs; + private Set m_expandedItems; private DictListAdapter m_adapter; private boolean m_quickFetchMode; @@ -222,12 +223,12 @@ public class DictsDelegate extends ListDelegateBase String name = info.m_name; item.setText( name ); + item.setCached( info ); item.setExpandedListener( DictsDelegate.this ); + item.setExpanded( m_expandedItems.contains( info ) ); item.setComment( m_onServerStr ); - item.setCached( info ); - if ( m_selDicts.containsKey( name ) ) { m_selDicts.put( name, item ); item.setSelected( true ); @@ -462,6 +463,8 @@ public class DictsDelegate extends ListDelegateBase m_closedLangs.addAll( Arrays.asList( closed ) ); } + m_expandedItems = new HashSet(); + m_locNames = getStringArray( R.array.loc_names ); m_noteNone = getString( R.string.note_none ); @@ -970,14 +973,15 @@ public class DictsDelegate extends ListDelegateBase } ////////////////////////////////////////////////////////////////////// - // XWListItem.ExpandedListener + // XWListItem.ExpandedListener interface ////////////////////////////////////////////////////////////////////// public void expanded( XWListItem me, boolean expanded ) { + final DictInfo info = (DictInfo)me.getCached(); if ( expanded ) { + m_expandedItems.add( info ); // may already be there LinearLayout view = (LinearLayout)inflate( R.layout.remote_dict_details ); - final DictInfo info = (DictInfo)me.getCached(); Button button = (Button)view.findViewById( R.id.download_button ); button.setOnClickListener( new View.OnClickListener() { public void onClick( View view ) { @@ -999,6 +1003,7 @@ public class DictsDelegate extends ListDelegateBase me.addExpandedView( view ); } else { me.removeExpandedView(); + m_expandedItems.remove( info ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListItem.java index 466b21cd1..8fbe7f95c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListItem.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListItem.java @@ -80,6 +80,14 @@ public class XWListItem extends LinearLayout setOnClickListener( this ); } + protected void setExpanded( boolean expanded ) + { + m_expanded = expanded; + if ( null != m_expListener ) { + m_expListener.expanded( this, m_expanded ); + } + } + protected void addExpandedView( View view ) { if ( null != m_expandedView ) { @@ -178,9 +186,8 @@ public class XWListItem extends LinearLayout { if ( m_checkbox == view ) { setSelected( m_checkbox.isChecked() ); - } else if ( null != m_expListener ) { - m_expanded = !m_expanded; - m_expListener.expanded( this, m_expanded ); + } else { + setExpanded( !m_expanded ); // toggle } }