mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
preserve scroll position across recreation of list adapters
This commit is contained in:
parent
ac2c960ef5
commit
f375defc0b
2 changed files with 14 additions and 7 deletions
|
@ -71,7 +71,6 @@ public class DictsDelegate extends ListDelegateBase
|
||||||
private String m_downloadStr;
|
private String m_downloadStr;
|
||||||
private ListView m_listView;
|
private ListView m_listView;
|
||||||
private String[] m_locNames;
|
private String[] m_locNames;
|
||||||
private DictListAdapter m_adapter;
|
|
||||||
private HashMap<String, XWListItem> m_selDicts;
|
private HashMap<String, XWListItem> m_selDicts;
|
||||||
private String m_origTitle;
|
private String m_origTitle;
|
||||||
|
|
||||||
|
@ -600,8 +599,13 @@ public class DictsDelegate extends ListDelegateBase
|
||||||
{
|
{
|
||||||
m_langs = DictLangCache.listLangs( m_activity );
|
m_langs = DictLangCache.listLangs( m_activity );
|
||||||
Arrays.sort( m_langs );
|
Arrays.sort( m_langs );
|
||||||
m_adapter = new DictListAdapter( m_activity );
|
|
||||||
m_activity.setListAdapter( m_adapter );
|
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 );
|
||||||
|
|
||||||
m_selDicts = new HashMap<String, XWListItem>();
|
m_selDicts = new HashMap<String, XWListItem>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ public class RemoteDictsDelegate extends ListDelegateBase
|
||||||
implements GroupStateListener, SelectableItem,
|
implements GroupStateListener, SelectableItem,
|
||||||
DwnldDelegate.DownloadFinishedListener {
|
DwnldDelegate.DownloadFinishedListener {
|
||||||
private ListActivity m_activity;
|
private ListActivity m_activity;
|
||||||
private ListView m_listView;
|
|
||||||
private boolean[] m_expanded;
|
private boolean[] m_expanded;
|
||||||
private String[] m_langNames;
|
private String[] m_langNames;
|
||||||
private static enum DictState { AVAILABLE, INSTALLED, NEEDS_UPDATE };
|
private static enum DictState { AVAILABLE, INSTALLED, NEEDS_UPDATE };
|
||||||
|
@ -74,7 +73,6 @@ public class RemoteDictsDelegate extends ListDelegateBase
|
||||||
protected void init( Bundle savedInstanceState )
|
protected void init( Bundle savedInstanceState )
|
||||||
{
|
{
|
||||||
setContentView( R.layout.remote_dicts );
|
setContentView( R.layout.remote_dicts );
|
||||||
m_listView = getListView();
|
|
||||||
JSONObject params = new JSONObject(); // empty for now
|
JSONObject params = new JSONObject(); // empty for now
|
||||||
m_origTitle = getTitle();
|
m_origTitle = getTitle();
|
||||||
|
|
||||||
|
@ -186,8 +184,13 @@ public class RemoteDictsDelegate extends ListDelegateBase
|
||||||
|
|
||||||
private void mkListAdapter()
|
private void mkListAdapter()
|
||||||
{
|
{
|
||||||
RDListAdapter adapter = new RDListAdapter();
|
ListView listView = getListView();
|
||||||
setListAdapter( adapter );
|
int pos = listView.getFirstVisiblePosition();
|
||||||
|
View child = listView.getChildAt( 0 );
|
||||||
|
int top = (child == null) ? 0 : child.getTop();
|
||||||
|
|
||||||
|
setListAdapter( new RDListAdapter() );
|
||||||
|
listView.setSelectionFromTop( pos, top );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTitleBar()
|
private void setTitleBar()
|
||||||
|
|
Loading…
Add table
Reference in a new issue