本文整理汇总了Java中android.view.textservice.SuggestionsInfo类的典型用法代码示例。如果您正苦于以下问题:Java SuggestionsInfo类的具体用法?Java SuggestionsInfo怎么用?Java SuggestionsInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SuggestionsInfo类属于android.view.textservice包,在下文中一共展示了SuggestionsInfo类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onGetSuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
/**
* http://www.tutorialspoint.com/android/android_spelling_checker.htm
* Sort of copy-paste, huh.
*
* I need to find time to refine this code
*
*
* @param results results
*/
@Override
public void onGetSuggestions(SuggestionsInfo[] results) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < results.length; ++i) {
// Returned suggestions are contained in SuggestionsInfo
final int len = results[i].getSuggestionsCount();
sb.append('\n');
for (int j = 0; j < len; ++j) {
sb.append("," + results[i].getSuggestionAt(j));
}
sb.append(" (" + len + ")");
}
}
开发者ID:VladThodo,项目名称:behe-keyboard,代码行数:26,代码来源:PCKeyboard.java
示例2: dumpSuggestionsInfoInternal
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
private void dumpSuggestionsInfoInternal(
final StringBuilder sb, final SuggestionsInfo si, final int length, final int offset) {
// Returned suggestions are contained in SuggestionsInfo
final int len = si.getSuggestionsCount();
sb.append('\n');
for (int j = 0; j < len; ++j) {
if (j != 0) {
sb.append(", ");
}
sb.append(si.getSuggestionAt(j));
}
sb.append(" (" + len + ")");
if (length != NOT_A_LENGTH) {
sb.append(" length = " + length + ", offset = " + offset);
}
}
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:17,代码来源:HelloSpellCheckerActivity.java
示例3: onGetSentenceSuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的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
示例4: onGetSuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
@Override
public void onGetSuggestions(SuggestionsInfo[] results) {
StringBuilder sb = new StringBuilder();
for (int i=0; i<results.length ;++i)
{
int len = results[i].getSuggestionsCount();
sb.append('\n');
for (int j=0; j<len; j++)
{
if(value.contentEquals(results[i].getSuggestionAt(j))==true)
{
rightbox.setText("Correct");
}
else
{
sb.append(results[i].getSuggestionAt(j)+"\n");
}
}
}
suggestbox.setText(sb.toString());
}
开发者ID:zoebchhatriwala,项目名称:CamWord,代码行数:22,代码来源:SpellChecker.java
示例5: onGetSuggestionsMultiple
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
@Override
public SuggestionsInfo[] onGetSuggestionsMultiple(TextInfo[] textInfos,
int suggestionsLimit, boolean sequentialWords) {
long ident = Binder.clearCallingIdentity();
try {
final int length = textInfos.length;
final SuggestionsInfo[] retval = new SuggestionsInfo[length];
for (int i = 0; i < length; ++i) {
final String prevWord;
if (sequentialWords && i > 0) {
final String prevWordCandidate = textInfos[i - 1].getText();
// Note that an empty string would be used to indicate the initial word
// in the future.
prevWord = TextUtils.isEmpty(prevWordCandidate) ? null : prevWordCandidate;
} else {
prevWord = null;
}
retval[i] = onGetSuggestionsInternal(textInfos[i], prevWord, suggestionsLimit);
retval[i].setCookieAndSequence(textInfos[i].getCookie(),
textInfos[i].getSequence());
}
return retval;
} finally {
Binder.restoreCallingIdentity(ident);
}
}
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:27,代码来源:AndroidSpellCheckerSession.java
示例6: dumpSuggestionsInfoInternal
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
private void dumpSuggestionsInfoInternal(
final List<String> sb, final SuggestionsInfo si, final int length, final int offset) {
// Returned suggestions are contained in SuggestionsInfo
final int len = si.getSuggestionsCount();
for (int j = 0; j < len; ++j) {
sb.add(si.getSuggestionAt(j));
}
}
开发者ID:VladThodo,项目名称:behe-keyboard,代码行数:9,代码来源:PCKeyboard.java
示例7: onGetSuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
/**
* Callback for {@link SpellCheckerSession#getSuggestions(TextInfo, int)}
* and {@link SpellCheckerSession#getSuggestions(TextInfo[], int, boolean)}
* @param results an array of {@link SuggestionsInfo}s.
* These results are suggestions for {@link TextInfo}s queried by
* {@link SpellCheckerSession#getSuggestions(TextInfo, int)} or
* {@link SpellCheckerSession#getSuggestions(TextInfo[], int, boolean)}
*/
@Override
public void onGetSuggestions(final SuggestionsInfo[] arg0) {
Log.d(TAG, "onGetSuggestions");
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < arg0.length; ++i) {
dumpSuggestionsInfoInternal(sb, arg0[i], 0, NOT_A_LENGTH);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
mMainView.append(sb.toString());
}
});
}
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:23,代码来源:HelloSpellCheckerActivity.java
示例8: reconstructSuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的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
示例9: onGetSuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
@Override
public SuggestionsInfo onGetSuggestions(final TextInfo textInfo, final int suggestionsLimit) {
long ident = Binder.clearCallingIdentity();
try {
return onGetSuggestionsInternal(textInfo, suggestionsLimit);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:10,代码来源:AndroidWordLevelSpellCheckerSession.java
示例10: onGetSuggestionsMultiple
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
@Override
public SuggestionsInfo[] onGetSuggestionsMultiple(TextInfo[] textInfos,
int suggestionsLimit, boolean sequentialWords) {
long ident = Binder.clearCallingIdentity();
try {
final int length = textInfos.length;
final SuggestionsInfo[] retval = new SuggestionsInfo[length];
for (int i = 0; i < length; ++i) {
final CharSequence prevWord;
if (sequentialWords && i > 0) {
final TextInfo prevTextInfo = textInfos[i - 1];
final CharSequence prevWordCandidate =
TextInfoCompatUtils.getCharSequenceOrString(prevTextInfo);
// Note that an empty string would be used to indicate the initial word
// in the future.
prevWord = TextUtils.isEmpty(prevWordCandidate) ? null : prevWordCandidate;
} else {
prevWord = null;
}
final NgramContext ngramContext =
new NgramContext(new NgramContext.WordInfo(prevWord));
final TextInfo textInfo = textInfos[i];
retval[i] = onGetSuggestionsInternal(textInfo, ngramContext, suggestionsLimit);
retval[i].setCookieAndSequence(textInfo.getCookie(), textInfo.getSequence());
}
return retval;
} finally {
Binder.restoreCallingIdentity(ident);
}
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:31,代码来源:AndroidSpellCheckerSession.java
示例11: onGetSentenceSuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的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
示例12: onGetSuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
@Override
public SuggestionsInfo onGetSuggestions(final TextInfo textInfo,
final int suggestionsLimit) {
long ident = Binder.clearCallingIdentity();
try {
return onGetSuggestionsInternal(textInfo, suggestionsLimit);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:11,代码来源:AndroidWordLevelSpellCheckerSession.java
示例13: getInDictEmptySuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
/**
* Returns an empty suggestionInfo with flags signaling the word is in the dictionary.
* @return the empty SuggestionsInfo with the appropriate flags set.
*/
public static SuggestionsInfo getInDictEmptySuggestions() {
return new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY,
EMPTY_STRING_ARRAY);
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:9,代码来源:AndroidSpellCheckerService.java
示例14: onGetSuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
@Override
public void onGetSuggestions(SuggestionsInfo[] results) {}
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:3,代码来源:SpellCheckerSessionBridge.java
示例15: getNotInDictEmptySuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
public static SuggestionsInfo getNotInDictEmptySuggestions() {
return new SuggestionsInfo(0, EMPTY_STRING_ARRAY);
}
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:4,代码来源:AndroidSpellCheckerService.java
示例16: getInDictEmptySuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
public static SuggestionsInfo getInDictEmptySuggestions() {
return new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY,
EMPTY_STRING_ARRAY);
}
开发者ID:slightfoot,项目名称:android-kioskime,代码行数:5,代码来源:AndroidSpellCheckerService.java
示例17: onGetSuggestionsInternal
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
/**
* Gets a list of suggestions for a specific string. This returns a list of possible
* corrections for the text passed as an argument. It may split or group words, and
* even perform grammatical analysis.
*/
private SuggestionsInfo onGetSuggestionsInternal(final TextInfo textInfo,
final int suggestionsLimit) {
return onGetSuggestionsInternal(textInfo, null, suggestionsLimit);
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:10,代码来源:AndroidWordLevelSpellCheckerSession.java
示例18: getNotInDictEmptySuggestions
import android.view.textservice.SuggestionsInfo; //导入依赖的package包/类
/**
* Returns an empty SuggestionsInfo with flags signaling the word is not in the dictionary.
* @param reportAsTypo whether this should include the flag LOOKS_LIKE_TYPO, for red underline.
* @return the empty SuggestionsInfo with the appropriate flags set.
*/
public static SuggestionsInfo getNotInDictEmptySuggestions(final boolean reportAsTypo) {
return new SuggestionsInfo(reportAsTypo ? SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO : 0,
EMPTY_STRING_ARRAY);
}
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:10,代码来源:AndroidSpellCheckerService.java
注:本文中的android.view.textservice.SuggestionsInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论