mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
add ability to look up by language name. Note: this code is hitting
the DB way too often and needs to be optimized!
This commit is contained in:
parent
45ebb8d3b9
commit
4e4175f486
1 changed files with 17 additions and 0 deletions
|
@ -41,6 +41,7 @@ import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||||
|
|
||||||
public class DictLangCache {
|
public class DictLangCache {
|
||||||
private static String[] s_langNames;
|
private static String[] s_langNames;
|
||||||
|
private static HashMap<String, Integer> s_langCodes;
|
||||||
|
|
||||||
private static int s_adaptedLang = -1;
|
private static int s_adaptedLang = -1;
|
||||||
private static ArrayAdapter<String> s_langsAdapter;
|
private static ArrayAdapter<String> s_langsAdapter;
|
||||||
|
@ -122,6 +123,17 @@ public class DictLangCache {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean haveDict( Context context, String lang, String name )
|
||||||
|
{
|
||||||
|
boolean result = false;
|
||||||
|
getLangNames( context ); /* inits s_langCodes */
|
||||||
|
Integer code = s_langCodes.get( lang );
|
||||||
|
if ( null != code ) {
|
||||||
|
result = haveDict( context, code, name );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean haveDict( Context context, int code, String name )
|
public static boolean haveDict( Context context, int code, String name )
|
||||||
{
|
{
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
@ -353,6 +365,11 @@ public class DictLangCache {
|
||||||
if ( null == s_langNames ) {
|
if ( null == s_langNames ) {
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
s_langNames = res.getStringArray( R.array.language_names );
|
s_langNames = res.getStringArray( R.array.language_names );
|
||||||
|
|
||||||
|
s_langCodes = new HashMap<String, Integer>();
|
||||||
|
for ( int ii = 0; ii < s_langNames.length; ++ii ) {
|
||||||
|
s_langCodes.put( s_langNames[ii], ii );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return s_langNames;
|
return s_langNames;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue