mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-26 09:58:20 +01:00
relaunch activity, with pararms in intent, every time min or max
changed. Can't figure any other way to change the list of section heads, as setListAdapter() is ignored when called a second time. Note: I got an assertion failure in the jni indexing code so there may be a bug here.
This commit is contained in:
parent
aab9fd9df2
commit
1889fbd78b
1 changed files with 18 additions and 6 deletions
|
@ -47,6 +47,8 @@ public class DictBrowseActivity extends XWListActivity
|
|||
implements View.OnClickListener, OnItemSelectedListener {
|
||||
|
||||
public static final String DICT_NAME = "DICT_NAME";
|
||||
public static final String DICT_MIN = "DICT_MIN";
|
||||
public static final String DICT_MAX = "DICT_MAX";
|
||||
|
||||
private static final int MIN_LEN = 2;
|
||||
|
||||
|
@ -56,7 +58,7 @@ public class DictBrowseActivity extends XWListActivity
|
|||
private float m_textSize;
|
||||
private Spinner m_minSpinner;
|
||||
private Spinner m_maxSpinner;
|
||||
private int m_min = MIN_LEN;
|
||||
private int m_min;
|
||||
private int m_max;
|
||||
|
||||
|
||||
|
@ -164,12 +166,15 @@ public class DictBrowseActivity extends XWListActivity
|
|||
}
|
||||
} );
|
||||
|
||||
m_min = intent.getIntExtra( DICT_MIN, MIN_LEN );
|
||||
|
||||
m_minSpinner = (Spinner)findViewById( R.id.wordlen_min );
|
||||
m_minSpinner.setOnItemSelectedListener( this );
|
||||
m_minSpinner.setSelection( 0 );
|
||||
m_minSpinner.setSelection( m_min - MIN_LEN );
|
||||
m_maxSpinner = (Spinner)findViewById( R.id.wordlen_max );
|
||||
m_maxSpinner.setOnItemSelectedListener( this );
|
||||
m_max = m_maxSpinner.getCount() + MIN_LEN - 1;
|
||||
m_max = intent.getIntExtra( DICT_MAX, m_max );
|
||||
m_maxSpinner.setSelection( m_max - MIN_LEN );
|
||||
|
||||
setListAdapter( new DictListAdapter() );
|
||||
|
@ -245,11 +250,18 @@ public class DictBrowseActivity extends XWListActivity
|
|||
|
||||
private void setMinMax( int min, int max )
|
||||
{
|
||||
// I can't make a second call to setListAdapter() work, nor
|
||||
// does notifyDataSetChanged do anything toward refreshing the
|
||||
// adapter/making it recognized a changed dataset. So, as a
|
||||
// workaround, relaunch the activity with different
|
||||
// parameters.
|
||||
if ( m_min != min || m_max != max ) {
|
||||
m_min = min;
|
||||
m_max = max;
|
||||
setListAdapter( new DictListAdapter() );
|
||||
Utils.logf( "setMinMax(%d,%d)", min, max );
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra( DICT_MIN, min );
|
||||
intent.putExtra( DICT_MAX, max );
|
||||
startActivity( intent );
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue