当前位置: 首页>>代码示例>>Java>>正文


Java SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO属性代码示例

本文整理汇总了Java中android.view.textservice.SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO属性的典型用法代码示例。如果您正苦于以下问题:Java SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO属性的具体用法?Java SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO怎么用?Java SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.textservice.SuggestionsInfo的用法示例。


在下文中一共展示了SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onGetSentenceSuggestions

/**
 * 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,代码行数:24,代码来源:SpellCheckerSessionBridge.java

示例2: onGetSentenceSuggestions

/**
 * 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,代码行数:38,代码来源:SpellCheckerSessionBridge.java

示例3: getNotInDictEmptySuggestions

/**
 * 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,代码行数:9,代码来源:AndroidSpellCheckerService.java


注:本文中的android.view.textservice.SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。