add static methods to count and list dicts in a given langauge.

This commit is contained in:
Andy2 2010-11-30 06:34:57 -08:00
parent 1653b9f6e9
commit 3a9eb72db3

View file

@ -22,6 +22,7 @@ package org.eehouse.android.xw4;
import android.content.Context;
import android.content.res.Resources;
import java.util.ArrayList;
import java.util.HashMap;
import org.eehouse.android.xw4.jni.JNIUtilsImpl;
@ -53,6 +54,32 @@ public class DictLangCache {
return namesArray[code];
}
// This populates the cache and will take significant time if it's
// mostly empty and there are a lot of dicts.
public static int getLangCount( Context context, int code )
{
int count = 0;
String[] dicts = GameUtils.dictList( context );
for ( String dict : dicts ) {
if ( code == getLangCode( context, dict ) ) {
++count;
}
}
return count;
}
public static String[] getHaveLang( Context context, int code )
{
ArrayList<String> al = new ArrayList<String>();
String[] dicts = GameUtils.dictList( context );
for ( String dict : dicts ) {
if ( code == getLangCode( context, dict ) ) {
al.add( dict );
}
}
return al.toArray( new String[al.size()] );
}
public static int getLangCode( Context context, String name )
{
int code;