Methods Summary |
---|
private boolean | getUsrDictFileName(byte[] usr_dict)
try {
System.loadLibrary("jni_pinyinime");
} catch (UnsatisfiedLinkError ule) {
Log.e("PinyinDecoderService",
"WARNING: Could not load jni_pinyinime natives");
}
if (null == usr_dict) {
return false;
}
for (int i = 0; i < mUsr_dict_file.length(); i++)
usr_dict[i] = (byte) mUsr_dict_file.charAt(i);
usr_dict[mUsr_dict_file.length()] = 0;
return true;
|
private void | initPinyinEngine()
byte usr_dict[];
usr_dict = new byte[MAX_PATH_FILE_LENGTH];
// Here is how we open a built-in dictionary for access through
// a file descriptor...
AssetFileDescriptor afd = getResources().openRawResourceFd(
R.raw.dict_pinyin);
if (Environment.getInstance().needDebug()) {
Log
.i("foo", "Dict: start=" + afd.getStartOffset()
+ ", length=" + afd.getLength() + ", fd="
+ afd.getParcelFileDescriptor());
}
if (getUsrDictFileName(usr_dict)) {
inited = nativeImOpenDecoderFd(afd.getFileDescriptor(), afd
.getStartOffset(), afd.getLength(), usr_dict);
}
try {
afd.close();
} catch (IOException e) {
}
|
static native int | nativeImAddLetter(byte ch)
|
static native boolean | nativeImCancelInput()
|
static native int | nativeImCancelLastChoice()
|
static native int | nativeImChoose(int choiceId)
|
static native boolean | nativeImCloseDecoder()
|
static native int | nativeImDelSearch(int pos, boolean is_pos_in_splid, boolean clear_fixed_this_step)
|
static native boolean | nativeImFlushCache()
|
static native java.lang.String | nativeImGetChoice(int choiceId)
|
static native int | nativeImGetFixedLen()
|
static native java.lang.String | nativeImGetPredictItem(int predictNo)
|
static native int | nativeImGetPredictsNum(java.lang.String fixedStr)
|
static native java.lang.String | nativeImGetPyStr(boolean decoded)
|
static native int | nativeImGetPyStrLen(boolean decoded)
|
static native int[] | nativeImGetSplStart()
|
static native boolean | nativeImOpenDecoder(byte[] fn_sys_dict, byte[] fn_usr_dict)
|
static native boolean | nativeImOpenDecoderFd(java.io.FileDescriptor fd, long startOffset, long length, byte[] fn_usr_dict)
|
static native void | nativeImResetSearch()
|
static native int | nativeImSearch(byte[] pyBuf, int pyLen)
|
static native void | nativeImSetMaxLens(int maxSpsLen, int maxHzsLen)
|
static native boolean | nativeSyncBegin(byte[] user_dict)
|
static native boolean | nativeSyncClearLastGot()
|
static native boolean | nativeSyncFinish()
|
static native int | nativeSyncGetCapacity()
|
static native int | nativeSyncGetLastCount()
|
static native java.lang.String | nativeSyncGetLemmas()
|
static native int | nativeSyncGetTotalCount()
|
static native int | nativeSyncPutLemmas(java.lang.String tomerge)
|
static native java.lang.String | nativeSyncUserDict(byte[] user_dict, java.lang.String tomerge)
|
public android.os.IBinder | onBind(android.content.Intent intent)
return mBinder;
|
public void | onCreate()
super.onCreate();
mUsr_dict_file = getFileStreamPath("usr_dict.dat").getPath();
// This is a hack to make sure our "files" directory has been
// created.
try {
openFileOutput("dummy", 0).close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
initPinyinEngine();
|
public void | onDestroy()
nativeImCloseDecoder();
inited = false;
super.onDestroy();
|