mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-06 20:45:54 +01:00
save search prefix too
This commit is contained in:
parent
ce6356fb92
commit
67b0d44f26
2 changed files with 23 additions and 2 deletions
|
@ -90,8 +90,9 @@ public class DBUtils {
|
||||||
public int m_maxShown;
|
public int m_maxShown;
|
||||||
public int m_pos;
|
public int m_pos;
|
||||||
public int m_top;
|
public int m_top;
|
||||||
public int[] m_counts;
|
public String m_prefix;
|
||||||
public int m_count;
|
public int m_count;
|
||||||
|
public int[] m_counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameSummary getSummary( Context context, long rowid,
|
public static GameSummary getSummary( Context context, long rowid,
|
||||||
|
@ -960,7 +961,8 @@ public class DBUtils {
|
||||||
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
||||||
String[] columns = { DBHelper.ITERPOS, DBHelper.ITERTOP,
|
String[] columns = { DBHelper.ITERPOS, DBHelper.ITERTOP,
|
||||||
DBHelper.ITERMIN, DBHelper.ITERMAX,
|
DBHelper.ITERMIN, DBHelper.ITERMAX,
|
||||||
DBHelper.WORDCOUNTS, DBHelper.WORDCOUNT };
|
DBHelper.WORDCOUNTS, DBHelper.WORDCOUNT,
|
||||||
|
DBHelper.ITERPREFIX };
|
||||||
String selection = String.format( NAME_FMT, DBHelper.DICTNAME, name );
|
String selection = String.format( NAME_FMT, DBHelper.DICTNAME, name );
|
||||||
Cursor cursor = db.query( DBHelper.TABLE_NAME_DICTS, columns,
|
Cursor cursor = db.query( DBHelper.TABLE_NAME_DICTS, columns,
|
||||||
selection, null, null, null, null );
|
selection, null, null, null, null );
|
||||||
|
@ -976,6 +978,9 @@ public class DBUtils {
|
||||||
result.m_maxShown =
|
result.m_maxShown =
|
||||||
cursor.getInt( cursor
|
cursor.getInt( cursor
|
||||||
.getColumnIndex(DBHelper.ITERMAX));
|
.getColumnIndex(DBHelper.ITERMAX));
|
||||||
|
result.m_prefix =
|
||||||
|
cursor.getString( cursor
|
||||||
|
.getColumnIndex(DBHelper.ITERPREFIX));
|
||||||
result.m_count =
|
result.m_count =
|
||||||
cursor.getInt( cursor.getColumnIndex(DBHelper.WORDCOUNT));
|
cursor.getInt( cursor.getColumnIndex(DBHelper.WORDCOUNT));
|
||||||
String counts =
|
String counts =
|
||||||
|
@ -1007,6 +1012,7 @@ public class DBUtils {
|
||||||
values.put( DBHelper.ITERTOP, state.m_top );
|
values.put( DBHelper.ITERTOP, state.m_top );
|
||||||
values.put( DBHelper.ITERMIN, state.m_minShown );
|
values.put( DBHelper.ITERMIN, state.m_minShown );
|
||||||
values.put( DBHelper.ITERMAX, state.m_maxShown );
|
values.put( DBHelper.ITERMAX, state.m_maxShown );
|
||||||
|
values.put( DBHelper.ITERPREFIX, state.m_prefix );
|
||||||
values.put( DBHelper.WORDCOUNT, state.m_count );
|
values.put( DBHelper.WORDCOUNT, state.m_count );
|
||||||
if ( null != state.m_counts ) {
|
if ( null != state.m_counts ) {
|
||||||
String[] nums = new String[state.m_counts.length];
|
String[] nums = new String[state.m_counts.length];
|
||||||
|
|
|
@ -239,6 +239,7 @@ public class DictBrowseActivity extends XWListActivity
|
||||||
if ( null == m_browseState ) {
|
if ( null == m_browseState ) {
|
||||||
m_browseState = DBUtils.dictsGetOffset( this, m_name );
|
m_browseState = DBUtils.dictsGetOffset( this, m_name );
|
||||||
}
|
}
|
||||||
|
showPrefix( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -308,6 +309,20 @@ public class DictBrowseActivity extends XWListActivity
|
||||||
EditText edit = (EditText)findViewById( R.id.word_edit );
|
EditText edit = (EditText)findViewById( R.id.word_edit );
|
||||||
String text = edit.getText().toString();
|
String text = edit.getText().toString();
|
||||||
if ( null != text && 0 < text.length() ) {
|
if ( null != text && 0 < text.length() ) {
|
||||||
|
m_browseState.m_prefix = text;
|
||||||
|
showPrefix( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showPrefix( boolean fillField )
|
||||||
|
{
|
||||||
|
String text = m_browseState.m_prefix;
|
||||||
|
if ( null != text && 0 < text.length() ) {
|
||||||
|
if ( fillField ) {
|
||||||
|
EditText edit = (EditText)findViewById( R.id.word_edit );
|
||||||
|
edit.setText( text );
|
||||||
|
}
|
||||||
|
|
||||||
int pos = XwJNI.dict_iter_getStartsWith( m_dictClosure, text );
|
int pos = XwJNI.dict_iter_getStartsWith( m_dictClosure, text );
|
||||||
if ( 0 <= pos ) {
|
if ( 0 <= pos ) {
|
||||||
getListView().setSelection( pos );
|
getListView().setSelection( pos );
|
||||||
|
|
Loading…
Add table
Reference in a new issue