2012-03-26 13:31:20 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.inputmethod.latin;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import com.android.inputmethod.keyboard.ProximityInfo;
|
2012-06-12 21:57:40 +00:00
|
|
|
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
2012-03-26 13:31:20 +00:00
|
|
|
|
2012-06-12 21:57:40 +00:00
|
|
|
import java.util.ArrayList;
|
2012-06-05 07:33:21 +00:00
|
|
|
import java.util.Locale;
|
|
|
|
|
2012-03-26 13:31:20 +00:00
|
|
|
public class SynchronouslyLoadedContactsBinaryDictionary extends ContactsBinaryDictionary {
|
|
|
|
private boolean mClosed;
|
|
|
|
|
2012-06-05 07:33:21 +00:00
|
|
|
public SynchronouslyLoadedContactsBinaryDictionary(final Context context, final Locale locale) {
|
|
|
|
super(context, Suggest.DIC_CONTACTS, locale);
|
2012-03-26 13:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-12 21:57:40 +00:00
|
|
|
public synchronized ArrayList<SuggestedWordInfo> getWords(final WordComposer codes,
|
2012-04-17 03:43:53 +00:00
|
|
|
final CharSequence prevWordForBigrams, final WordCallback callback,
|
2012-03-26 13:31:20 +00:00
|
|
|
final ProximityInfo proximityInfo) {
|
|
|
|
syncReloadDictionaryIfRequired();
|
2012-06-12 21:57:40 +00:00
|
|
|
return getWordsInner(codes, prevWordForBigrams, callback, proximityInfo);
|
2012-03-26 13:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public synchronized boolean isValidWord(CharSequence word) {
|
|
|
|
syncReloadDictionaryIfRequired();
|
|
|
|
return isValidWordInner(word);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Protect against multiple closing
|
|
|
|
@Override
|
|
|
|
public synchronized void close() {
|
|
|
|
// Actually with the current implementation of ContactsDictionary it's safe to close
|
|
|
|
// several times, so the following protection is really only for foolproofing
|
|
|
|
if (mClosed) return;
|
|
|
|
mClosed = true;
|
|
|
|
super.close();
|
|
|
|
}
|
2012-06-05 07:33:21 +00:00
|
|
|
}
|