mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
move into superclass
This commit is contained in:
parent
9cfacf6667
commit
26a8bf418f
3 changed files with 18 additions and 19 deletions
|
@ -102,9 +102,7 @@ public class DictsDelegate extends ListDelegateBase
|
|||
int lang = DictLangCache.getLangLangCode( m_context, langName );
|
||||
DictAndLoc[] dals = DictLangCache.getDALsHaveLang( m_context, lang );
|
||||
if ( null != dals ) {
|
||||
for ( DictAndLoc dal : dals ) {
|
||||
alist.add( dal );
|
||||
}
|
||||
alist.addAll( Arrays.asList(dals) );
|
||||
}
|
||||
}
|
||||
m_listInfo = alist.toArray( new Object[alist.size()] );
|
||||
|
@ -600,12 +598,7 @@ public class DictsDelegate extends ListDelegateBase
|
|||
m_langs = DictLangCache.listLangs( m_activity );
|
||||
Arrays.sort( m_langs );
|
||||
|
||||
int pos = m_listView.getFirstVisiblePosition();
|
||||
View child = m_listView.getChildAt( 0 );
|
||||
int top = (child == null) ? 0 : child.getTop();
|
||||
|
||||
setListAdapter( new DictListAdapter( m_activity ) );
|
||||
m_listView.setSelectionFromTop( pos, top );
|
||||
setListAdapterKeepScroll( new DictListAdapter( m_activity ) );
|
||||
|
||||
m_selDicts = new HashMap<String, XWListItem>();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eehouse.android.xw4;
|
|||
|
||||
import android.app.ListActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
|
@ -55,4 +56,16 @@ public class ListDelegateBase extends DelegateBase {
|
|||
{
|
||||
return m_activity.getListView();
|
||||
}
|
||||
|
||||
protected void setListAdapterKeepScroll( ListAdapter adapter )
|
||||
{
|
||||
ListView listView = getListView();
|
||||
int pos = listView.getFirstVisiblePosition();
|
||||
View child = listView.getChildAt( 0 );
|
||||
int top = (null == child) ? 0 : child.getTop();
|
||||
|
||||
setListAdapter( adapter );
|
||||
listView.setSelectionFromTop( pos, top );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -216,13 +216,7 @@ public class RemoteDictsDelegate extends ListDelegateBase
|
|||
|
||||
private void mkListAdapter()
|
||||
{
|
||||
ListView listView = getListView();
|
||||
int pos = listView.getFirstVisiblePosition();
|
||||
View child = listView.getChildAt( 0 );
|
||||
int top = (child == null) ? 0 : child.getTop();
|
||||
|
||||
setListAdapter( new RDListAdapter() );
|
||||
listView.setSelectionFromTop( pos, top );
|
||||
setListAdapterKeepScroll( new RDListAdapter() );
|
||||
}
|
||||
|
||||
private void setTitleBar()
|
||||
|
@ -373,9 +367,8 @@ public class RemoteDictsDelegate extends ListDelegateBase
|
|||
for ( int ii = 0; ii < nLangs; ++ii ) {
|
||||
alist.add( new Integer(ii) );
|
||||
if ( m_expanded[ii] ) {
|
||||
for ( DictInfo di : m_langInfo.get( m_langNames[ii] ) ) {
|
||||
alist.add( di );
|
||||
}
|
||||
DictInfo[] dis = m_langInfo.get( m_langNames[ii] );
|
||||
alist.addAll( Arrays.asList( dis ) );
|
||||
}
|
||||
}
|
||||
m_listInfo = alist.toArray( new Object[alist.size()] );
|
||||
|
|
Loading…
Reference in a new issue