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


Java BaseInputConnection.getComposingSpanEnd方法代码示例

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


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

示例1: shouldAutocomplete

import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
/**
 * Whether we want to be showing inline autocomplete results. We don't want to show them as the
 * user deletes input. Also if there is a composition (e.g. while using the Japanese IME),
 * we must not autocomplete or we'll destroy the composition.
 * @return Whether we want to be showing inline autocomplete results.
 */
public boolean shouldAutocomplete() {
    if (mLastUrlEditWasDelete) return false;
    Editable text = getText();

    return isCursorAtEndOfTypedText()
            && !isPastedText()
            && !isHandlingBatchInput()
            && BaseInputConnection.getComposingSpanEnd(text)
                    == BaseInputConnection.getComposingSpanStart(text);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:UrlBar.java

示例2: shouldAutocomplete

import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
/**
 * Whether we want to be showing inline autocomplete results. We don't want to show them as the
 * user deletes input. Also if there is a composition (e.g. while using the Japanese IME),
 * we must not autocomplete or we'll destroy the composition.
 * @return Whether we want to be showing inline autocomplete results.
 */
private boolean shouldAutocomplete() {
    if (mLastUrlEditWasDelete) return false;
    Editable text = mUrlBar.getText();

    return mUrlBar.isCursorAtEndOfTypedText()
            && !mUrlBar.isHandlingBatchInput()
            && BaseInputConnection.getComposingSpanEnd(text)
                    == BaseInputConnection.getComposingSpanStart(text);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:16,代码来源:LocationBarLayout.java

示例3: shouldAutocomplete

import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
/**
 * Whether we want to be showing inline autocomplete results. We don't want to show them as the
 * user deletes input. Also if there is a composition (e.g. while using the Japanese IME),
 * we must not autocomplete or we'll destroy the composition.
 * @return Whether we want to be showing inline autocomplete results.
 */
public boolean shouldAutocomplete() {
    if (mLastEditWasDelete) return false;
    Editable text = getText();

    return isCursorAtEndOfTypedText() && !isHandlingBatchInput()
            && BaseInputConnection.getComposingSpanEnd(text)
            == BaseInputConnection.getComposingSpanStart(text);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:AutocompleteEditText.java

示例4: setComposingText

import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
@Override
public boolean setComposingText(CharSequence text, int newCursorPosition) {
    Editable currentText = getText();
    int autoCompleteSpanStart = currentText.getSpanStart(mAutocompleteSpan);
    if (autoCompleteSpanStart >= 0) {
        int composingEnd = BaseInputConnection.getComposingSpanEnd(currentText);

        // On certain device/keyboard combinations, the composing regions are specified
        // with a noticeable delay after the initial character is typed, and in certain
        // circumstances it does not check that the current state of the text matches the
        // expectations of it's composing region.
        // For example, you can be typing:
        //   chrome://f
        // Chrome will autocomplete to:
        //   chrome://f[lags]
        // And after the autocomplete has been set, the keyboard will set the composing
        // region to the last character and it assumes it is 'f' as it was the last
        // character the keyboard sent.  If we commit this composition, the text will
        // look like:
        //   chrome://flag[f]
        // And if we use the autocomplete clearing logic below, it will look like:
        //   chrome://f[f]
        // To work around this, we see if the composition matches all the characters prior
        // to the autocomplete and just readjust the composing region to be that subset.
        //
        // See crbug.com/366732
        if (composingEnd == currentText.length()
                && autoCompleteSpanStart >= text.length()
                && TextUtils.equals(
                        currentText.subSequence(
                                autoCompleteSpanStart - text.length(),
                                autoCompleteSpanStart),
                        text)) {
            setComposingRegion(
                    autoCompleteSpanStart - text.length(), autoCompleteSpanStart);
        }

        // Once composing text is being modified, the autocomplete text has been accepted
        // or has to be deleted.
        mAutocompleteSpan.clearSpan();
        Selection.setSelection(currentText, autoCompleteSpanStart);
        currentText.delete(autoCompleteSpanStart, currentText.length());
    }
    return super.setComposingText(text, newCursorPosition);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:46,代码来源:UrlBar.java

示例5: setComposingText

import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
@Override
public boolean setComposingText(CharSequence text, int newCursorPosition) {
    if (DEBUG) Log.i(TAG, "setComposingText: [%s]", text);
    Editable currentText = getText();
    int autoCompleteSpanStart = currentText.getSpanStart(mAutocompleteSpan);
    if (autoCompleteSpanStart >= 0) {
        int composingEnd = BaseInputConnection.getComposingSpanEnd(currentText);

        // On certain device/keyboard combinations, the composing regions are specified
        // with a noticeable delay after the initial character is typed, and in certain
        // circumstances it does not check that the current state of the text matches the
        // expectations of it's composing region.
        // For example, you can be typing:
        //   chrome://f
        // Chrome will autocomplete to:
        //   chrome://f[lags]
        // And after the autocomplete has been set, the keyboard will set the composing
        // region to the last character and it assumes it is 'f' as it was the last
        // character the keyboard sent.  If we commit this composition, the text will
        // look like:
        //   chrome://flag[f]
        // And if we use the autocomplete clearing logic below, it will look like:
        //   chrome://f[f]
        // To work around this, we see if the composition matches all the characters prior
        // to the autocomplete and just readjust the composing region to be that subset.
        //
        // See crbug.com/366732
        if (composingEnd == currentText.length() && autoCompleteSpanStart >= text.length()
                && TextUtils.equals(
                           currentText.subSequence(autoCompleteSpanStart - text.length(),
                                   autoCompleteSpanStart),
                           text)) {
            setComposingRegion(
                    autoCompleteSpanStart - text.length(), autoCompleteSpanStart);
        }

        // Once composing text is being modified, the autocomplete text has been accepted
        // or has to be deleted.
        mAutocompleteSpan.clearSpan();
        Selection.setSelection(currentText, autoCompleteSpanStart);
        currentText.delete(autoCompleteSpanStart, currentText.length());
    }
    return super.setComposingText(text, newCursorPosition);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:45,代码来源:AutocompleteEditText.java


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