當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。