本文整理汇总了Java中android.view.textservice.SentenceSuggestionsInfo.getSuggestionsCount方法的典型用法代码示例。如果您正苦于以下问题:Java SentenceSuggestionsInfo.getSuggestionsCount方法的具体用法?Java SentenceSuggestionsInfo.getSuggestionsCount怎么用?Java SentenceSuggestionsInfo.getSuggestionsCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.textservice.SentenceSuggestionsInfo
的用法示例。
在下文中一共展示了SentenceSuggestionsInfo.getSuggestionsCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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){}
}
示例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());
}
});
}
示例3: 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));
}
示例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) {
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);
}