From d8f52a4f18d22aa150846b01017410ce70bbad6f Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 27 Apr 2011 23:13:11 +0900 Subject: 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 --- .../android/inputmethod/latin/DictionaryFactory.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/DictionaryFactory.java') 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 dictList = new LinkedList(); + 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); -- cgit v1.2.3-83-g751a