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-09-27 09:16:16 +00:00
|
|
|
public final class SynchronouslyLoadedContactsBinaryDictionary extends ContactsBinaryDictionary {
|
2012-03-26 13:31:20 +00:00
|
|
|
private boolean mClosed;
|
|
|
|
|
2012-06-05 07:33:21 +00:00
|
|
|
public SynchronouslyLoadedContactsBinaryDictionary(final Context context, final Locale locale) {
|
2012-06-27 08:31:09 +00:00
|
|
|
super(context, locale);
|
2012-03-26 13:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-07-09 11:13:22 +00:00
|
|
|
public synchronized ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
|
2013-05-01 11:36:36 +00:00
|
|
|
final String prevWordForBigrams, final ProximityInfo proximityInfo,
|
|
|
|
final boolean blockOffensiveWords) {
|
2012-03-26 13:31:20 +00:00
|
|
|
syncReloadDictionaryIfRequired();
|
2013-05-01 11:36:36 +00:00
|
|
|
return super.getSuggestions(codes, prevWordForBigrams, proximityInfo, blockOffensiveWords);
|
2012-03-26 13:31:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-10-03 06:19:43 +00:00
|
|
|
public synchronized boolean isValidWord(final String word) {
|
2012-03-26 13:31:20 +00:00
|
|
|
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
|
|
|
}
|