From 5b00d74c2efbf66cb13b856a7a7ed1437366a54d Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Wed, 2 Apr 2014 22:17:18 +0900 Subject: [PATCH] Use fixed order of dictionaries to get suggestions. Bug: 8187060 Change-Id: Id287776e3a82c0a6b208d677b8f2891266c5fc8d --- .../latin/DictionaryFacilitatorForSuggest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java index ae2d7c9c6..9c6aa552c 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -54,6 +53,15 @@ public class DictionaryFacilitatorForSuggest { // To synchronize assigning mDictionaries to ensure closing dictionaries. private Object mLock = new Object(); + private static final String[] dictTypesOrderedToGetSuggestion = + new String[] { + Dictionary.TYPE_MAIN, + Dictionary.TYPE_USER_HISTORY, + Dictionary.TYPE_PERSONALIZATION, + Dictionary.TYPE_USER, + Dictionary.TYPE_CONTACTS + }; + /** * Class contains dictionaries for a locale. */ @@ -453,7 +461,8 @@ public class DictionaryFacilitatorForSuggest { final Map dictMap = dictionaries.mDictMap; final SuggestionResults suggestionResults = new SuggestionResults(dictionaries.mLocale, SuggestedWords.MAX_SUGGESTIONS); - for (final Dictionary dictionary : dictMap.values()) { + for (final String dictType : dictTypesOrderedToGetSuggestion) { + final Dictionary dictionary = dictMap.get(dictType); if (null == dictionary) continue; final ArrayList dictionarySuggestions = dictionary.getSuggestionsWithSessionId(composer, prevWord, proximityInfo,