本文整理汇总了Java中android.view.textservice.SentenceSuggestionsInfo类的典型用法代码示例。如果您正苦于以下问题:Java SentenceSuggestionsInfo类的具体用法?Java SentenceSuggestionsInfo怎么用?Java SentenceSuggestionsInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SentenceSuggestionsInfo类属于android.view.textservice包,在下文中一共展示了SentenceSuggestionsInfo类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onGetSentenceSuggestions
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
try {
final List<String> sb = new ArrayList<>();
for (int i = 0; i < results.length; ++i) {
final SentenceSuggestionsInfo ssi = results[i];
for (int j = 0; j < ssi.getSuggestionsCount(); ++j) {
dumpSuggestionsInfoInternal(
sb, ssi.getSuggestionsInfoAt(j), ssi.getOffsetAt(j), ssi.getLengthAt(j));
}
}
setSuggestions(sb, true, true);
}
catch(Exception e){}
}
开发者ID:VladThodo,项目名称:behe-keyboard,代码行数:19,代码来源:PCKeyboard.java
示例2: onGetSentenceSuggestions
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
/**
* Callback for {@link SpellCheckerSession#getSentenceSuggestions(TextInfo[], int)}
* @param results an array of {@link SentenceSuggestionsInfo}s.
* These results are suggestions for {@link TextInfo}s
* queried by {@link SpellCheckerSession#getSentenceSuggestions(TextInfo[], int)}.
*/
@Override
public void onGetSentenceSuggestions(final SentenceSuggestionsInfo[] arg0) {
if (!isSentenceSpellCheckSupported()) {
Log.e(TAG, "Sentence spell check is not supported on this platform, "
+ "but accidentially called.");
return;
}
Log.d(TAG, "onGetSentenceSuggestions");
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < arg0.length; ++i) {
final SentenceSuggestionsInfo ssi = arg0[i];
for (int j = 0; j < ssi.getSuggestionsCount(); ++j) {
dumpSuggestionsInfoInternal(
sb, ssi.getSuggestionsInfoAt(j), ssi.getOffsetAt(j), ssi.getLengthAt(j));
}
}
runOnUiThread(new Runnable() {
@Override
public void run() {
mMainView.append(sb.toString());
}
});
}
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:30,代码来源:HelloSpellCheckerActivity.java
示例3: onGetSentenceSuggestionsMultiple
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
@Override
public SentenceSuggestionsInfo[] onGetSentenceSuggestionsMultiple(TextInfo[] textInfos,
int suggestionsLimit) {
final SentenceSuggestionsInfo[] retval = splitAndSuggest(textInfos, suggestionsLimit);
if (retval == null || retval.length != textInfos.length) {
return retval;
}
for (int i = 0; i < retval.length; ++i) {
final SentenceSuggestionsInfo tempSsi =
fixWronglyInvalidatedWordWithSingleQuote(textInfos[i], retval[i]);
if (tempSsi != null) {
retval[i] = tempSsi;
}
}
return retval;
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:17,代码来源:AndroidSpellCheckerSession.java
示例4: onGetSentenceSuggestions
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
/**
* Checks for typos and sends results back to native through a JNI call.
* @param results Results returned by the Android spellchecker.
*/
@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
ArrayList<Integer> offsets = new ArrayList<Integer>();
ArrayList<Integer> lengths = new ArrayList<Integer>();
for (SentenceSuggestionsInfo result : results) {
for (int i = 0; i < result.getSuggestionsCount(); i++) {
// If a word looks like a typo, record its offset and length.
if ((result.getSuggestionsInfoAt(i).getSuggestionsAttributes()
& SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO)
== SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO) {
offsets.add(result.getOffsetAt(i));
lengths.add(result.getLengthAt(i));
}
}
}
nativeProcessSpellCheckResults(mNativeSpellCheckerSessionBridge,
convertListToArray(offsets), convertListToArray(lengths));
}
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:25,代码来源:SpellCheckerSessionBridge.java
示例5: onGetSentenceSuggestionsMultiple
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
@Override
public SentenceSuggestionsInfo[] onGetSentenceSuggestionsMultiple(TextInfo[] textInfos,
int suggestionsLimit) {
final SentenceSuggestionsInfo[] retval =
super.onGetSentenceSuggestionsMultiple(textInfos, suggestionsLimit);
if (retval == null || retval.length != textInfos.length) {
return retval;
}
for (int i = 0; i < retval.length; ++i) {
final SentenceSuggestionsInfo tempSsi =
fixWronglyInvalidatedWordWithSingleQuote(textInfos[i], retval[i]);
if (tempSsi != null) {
retval[i] = tempSsi;
}
}
return retval;
}
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:18,代码来源:AndroidSpellCheckerSession.java
示例6: reconstructSuggestions
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static SentenceSuggestionsInfo reconstructSuggestions(
SentenceTextInfoParams originalTextInfoParams, SuggestionsInfo[] results) {
if (results == null || results.length == 0) {
return null;
}
if (originalTextInfoParams == null) {
return null;
}
final int originalCookie = originalTextInfoParams.mOriginalTextInfo.getCookie();
final int originalSequence =
originalTextInfoParams.mOriginalTextInfo.getSequence();
final int querySize = originalTextInfoParams.mSize;
final int[] offsets = new int[querySize];
final int[] lengths = new int[querySize];
final SuggestionsInfo[] reconstructedSuggestions = new SuggestionsInfo[querySize];
for (int i = 0; i < querySize; ++i) {
final SentenceWordItem item = originalTextInfoParams.mItems.get(i);
SuggestionsInfo result = null;
for (int j = 0; j < results.length; ++j) {
final SuggestionsInfo cur = results[j];
if (cur != null && cur.getSequence() == item.mTextInfo.getSequence()) {
result = cur;
result.setCookieAndSequence(originalCookie, originalSequence);
break;
}
}
offsets[i] = item.mStart;
lengths[i] = item.mLength;
reconstructedSuggestions[i] = result != null ? result : EMPTY_SUGGESTIONS_INFO;
}
return new SentenceSuggestionsInfo(reconstructedSuggestions, offsets, lengths);
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:35,代码来源:SentenceLevelAdapter.java
示例7: splitAndSuggest
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
/**
* Get sentence suggestions for specified texts in an array of TextInfo. This is taken from
* SpellCheckerService#onGetSentenceSuggestionsMultiple that we can't use because it's
* using private variables.
* The default implementation splits the input text to words and returns
* {@link SentenceSuggestionsInfo} which contains suggestions for each word.
* This function will run on the incoming IPC thread.
* So, this is not called on the main thread,
* but will be called in series on another thread.
* @param textInfos an array of the text metadata
* @param suggestionsLimit the maximum number of suggestions to be returned
* @return an array of {@link SentenceSuggestionsInfo} returned by
* {@link android.service.textservice.SpellCheckerService.Session#onGetSuggestions(TextInfo, int)}
*/
private SentenceSuggestionsInfo[] splitAndSuggest(TextInfo[] textInfos, int suggestionsLimit) {
if (textInfos == null || textInfos.length == 0) {
return SentenceLevelAdapter.getEmptySentenceSuggestionsInfo();
}
SentenceLevelAdapter sentenceLevelAdapter;
synchronized(this) {
sentenceLevelAdapter = mSentenceLevelAdapter;
if (sentenceLevelAdapter == null) {
final String localeStr = getLocale();
if (!TextUtils.isEmpty(localeStr)) {
sentenceLevelAdapter = new SentenceLevelAdapter(mResources,
new Locale(localeStr));
mSentenceLevelAdapter = sentenceLevelAdapter;
}
}
}
if (sentenceLevelAdapter == null) {
return SentenceLevelAdapter.getEmptySentenceSuggestionsInfo();
}
final int infosSize = textInfos.length;
final SentenceSuggestionsInfo[] retval = new SentenceSuggestionsInfo[infosSize];
for (int i = 0; i < infosSize; ++i) {
final SentenceLevelAdapter.SentenceTextInfoParams textInfoParams =
sentenceLevelAdapter.getSplitWords(textInfos[i]);
final ArrayList<SentenceLevelAdapter.SentenceWordItem> mItems =
textInfoParams.mItems;
final int itemsSize = mItems.size();
final TextInfo[] splitTextInfos = new TextInfo[itemsSize];
for (int j = 0; j < itemsSize; ++j) {
splitTextInfos[j] = mItems.get(j).mTextInfo;
}
retval[i] = SentenceLevelAdapter.reconstructSuggestions(
textInfoParams, onGetSuggestionsMultiple(
splitTextInfos, suggestionsLimit, true));
}
return retval;
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:52,代码来源:AndroidSpellCheckerSession.java
示例8: onGetSentenceSuggestions
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
/**
* Checks for typos and sends results back to native through a JNI call.
* @param results Results returned by the Android spellchecker.
*/
@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
mStopMs = SystemClock.elapsedRealtime();
if (mNativeSpellCheckerSessionBridge == 0) {
return;
}
ArrayList<Integer> offsets = new ArrayList<Integer>();
ArrayList<Integer> lengths = new ArrayList<Integer>();
for (SentenceSuggestionsInfo result : results) {
if (result == null) {
// In some cases null can be returned by the selected spellchecking service,
// see crbug.com/651458. In this case skip to next result to avoid a
// NullPointerException later on.
continue;
}
for (int i = 0; i < result.getSuggestionsCount(); i++) {
// If a word looks like a typo, record its offset and length.
if ((result.getSuggestionsInfoAt(i).getSuggestionsAttributes()
& SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO)
== SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO) {
offsets.add(result.getOffsetAt(i));
lengths.add(result.getLengthAt(i));
}
}
}
nativeProcessSpellCheckResults(mNativeSpellCheckerSessionBridge,
convertListToArray(offsets), convertListToArray(lengths));
RecordHistogram.recordTimesHistogram("SpellCheck.Android.Latency",
mStopMs - mStartMs, TimeUnit.MILLISECONDS);
}
开发者ID:mogoweb,项目名称:365browser,代码行数:39,代码来源:SpellCheckerSessionBridge.java
示例9: getEmptySentenceSuggestionsInfo
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
public static SentenceSuggestionsInfo[] getEmptySentenceSuggestionsInfo() {
return EmptySentenceSuggestionsInfosInitializationHolder.EMPTY_SENTENCE_SUGGESTIONS_INFOS;
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:4,代码来源:SentenceLevelAdapter.java
示例10: onGetSentenceSuggestions
import android.view.textservice.SentenceSuggestionsInfo; //导入依赖的package包/类
@Override
public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] results) {
}
开发者ID:zoebchhatriwala,项目名称:CamWord,代码行数:6,代码来源:SpellChecker.java
注:本文中的android.view.textservice.SentenceSuggestionsInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论