diff options
author | 2011-04-27 23:13:11 +0900 | |
---|---|---|
committer | 2011-04-28 16:16:46 +0900 | |
commit | d8f52a4f18d22aa150846b01017410ce70bbad6f (patch) | |
tree | 596b3ee1c0ea36647a234c5ecdd5aef0e3afe78e /java/src/com/android/inputmethod/latin/DictionaryFactory.java | |
parent | 3bf6fbb6b8765a90e19199e5dfeb7df26d04bb68 (diff) | |
download | latinime-d8f52a4f18d22aa150846b01017410ce70bbad6f.tar.gz latinime-d8f52a4f18d22aa150846b01017410ce70bbad6f.tar.xz latinime-d8f52a4f18d22aa150846b01017410ce70bbad6f.zip |
Improve the architecture to support multiple dictionaries.
This change enables the interface to get multiple dictionaries from a
dictionary pack. It only implements it to the end in the case of the
proprietary method, as the open method needs still some working out,
and the "inside the package" method does not need it.
This change goes together with Iaa95bf36, and breaks the build
without it.
Bug: 1752028
Change-Id: I3ccfd696e8ef083ef9c074e1c3e4bb0bf2fcfd23
Diffstat (limited to 'java/src/com/android/inputmethod/latin/DictionaryFactory.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/DictionaryFactory.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFactory.java b/java/src/com/android/inputmethod/latin/DictionaryFactory.java index 2dbd582f3..605676d70 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFactory.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFactory.java @@ -18,11 +18,12 @@ package com.android.inputmethod.latin; import android.content.Context; import android.content.res.AssetFileDescriptor; -import android.content.res.Configuration; import android.content.res.Resources; import android.util.Log; import java.io.File; +import java.util.LinkedList; +import java.util.List; import java.util.Locale; /** @@ -50,11 +51,14 @@ public class DictionaryFactory { return new DictionaryCollection(createBinaryDictionary(context, fallbackResId)); } - final AssetFileAddress dictFile = BinaryDictionaryGetter.getDictionaryFile(locale, - context, fallbackResId); - if (null == dictFile) return null; - return new DictionaryCollection(new BinaryDictionary(context, - dictFile.mFilename, dictFile.mOffset, dictFile.mLength, null)); + final List<Dictionary> dictList = new LinkedList<Dictionary>(); + for (final AssetFileAddress f : BinaryDictionaryGetter.getDictionaryFiles(locale, + context, fallbackResId)) { + dictList.add(new BinaryDictionary(context, f.mFilename, f.mOffset, f.mLength, null)); + } + + if (null == dictList) return null; + return new DictionaryCollection(dictList); } /** @@ -66,7 +70,6 @@ public class DictionaryFactory { protected static BinaryDictionary createBinaryDictionary(Context context, int resId) { AssetFileDescriptor afd = null; try { - // TODO: IMPORTANT: Do not create a dictionary from a placeholder. afd = context.getResources().openRawResourceFd(resId); if (afd == null) { Log.e(TAG, "Found the resource but it is compressed. resId=" + resId); |