类android.view.inputmethod.CursorAnchorInfo源码实例Demo

下面列出了怎么用android.view.inputmethod.CursorAnchorInfo的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android_9.0.0_r45   文件: InputMethodService.java
/**
 * Call {@link InputMethodService#onUpdateCursorAnchorInfo
 * InputMethodService.onUpdateCursorAnchorInfo()}.
 */
public void updateCursorAnchorInfo(CursorAnchorInfo info) {
    if (!isEnabled()) {
        return;
    }
    InputMethodService.this.onUpdateCursorAnchorInfo(info);
}
 
源代码2 项目: FirefoxReality   文件: Session.java
@Override
public void updateCursorAnchorInfo(@NonNull GeckoSession aSession, @NonNull CursorAnchorInfo info) {
    if (mState.mSession == aSession) {
        for (GeckoSession.TextInputDelegate listener : mTextInputListeners) {
            listener.updateCursorAnchorInfo(aSession, info);
        }
    }
}
 
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Nullable
public static CursorAnchorInfoCompatWrapper wrap(@Nullable final CursorAnchorInfo instance) {
    if (BuildCompatUtils.EFFECTIVE_SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return null;
    }
    if (instance == null) {
        return null;
    }
    return new RealWrapper(instance);
}
 
源代码4 项目: 365browser   文件: InputMethodManagerWrapper.java
/**
 * @see android.view.inputmethod.InputMethodManager#updateCursorAnchorInfo(View,
 * CursorAnchorInfo)
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void updateCursorAnchorInfo(View view, CursorAnchorInfo cursorAnchorInfo) {
    if (DEBUG_LOGS) Log.i(TAG, "updateCursorAnchorInfo");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getInputMethodManager().updateCursorAnchorInfo(view, cursorAnchorInfo);
    }
}
 
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Nullable
public static CursorAnchorInfoCompatWrapper wrap(@Nullable final CursorAnchorInfo instance) {
    if (BuildCompatUtils.EFFECTIVE_SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return null;
    }
    if (instance == null) {
        return null;
    }
    return new RealWrapper(instance);
}
 
@Override
public void updateCursorAnchorInfo(CursorAnchorInfo cursorAnchorInfo) {
    mCaller.executeOrSendMessage(
            mCaller.obtainMessageO(DO_UPDATE_CURSOR_ANCHOR_INFO, cursorAnchorInfo));
}
 
public RealWrapper(@Nonnull final CursorAnchorInfo info) {
    mInstance = info;
}
 
源代码8 项目: 365browser   文件: CursorAnchorInfoController.java
/**
 * Computes the CursorAnchorInfo instance and notify to InputMethodManager if needed.
 */
private void updateCursorAnchorInfo(View view) {
    if (!mHasCoordinateInfo) return;

    if (mLastCursorAnchorInfo == null) {
        // Reuse the builder object.
        mCursorAnchorInfoBuilder.reset();

        CharSequence text = mComposingTextDelegate.getText();
        int selectionStart = mComposingTextDelegate.getSelectionStart();
        int selectionEnd = mComposingTextDelegate.getSelectionEnd();
        int composingTextStart = mComposingTextDelegate.getComposingTextStart();
        int composingTextEnd = mComposingTextDelegate.getComposingTextEnd();
        if (text != null && 0 <= composingTextStart && composingTextEnd <= text.length()) {
            mCursorAnchorInfoBuilder.setComposingText(composingTextStart,
                    text.subSequence(composingTextStart, composingTextEnd));
            float[] compositionCharacterBounds = mCompositionCharacterBounds;
            if (compositionCharacterBounds != null) {
                int numCharacter = compositionCharacterBounds.length / 4;
                for (int i = 0; i < numCharacter; ++i) {
                    float left = compositionCharacterBounds[i * 4];
                    float top = compositionCharacterBounds[i * 4 + 1];
                    float right = compositionCharacterBounds[i * 4 + 2];
                    float bottom = compositionCharacterBounds[i * 4 + 3];
                    int charIndex = composingTextStart + i;
                    mCursorAnchorInfoBuilder.addCharacterBounds(charIndex, left, top, right,
                            bottom, CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION);
                }
            }
        }
        mCursorAnchorInfoBuilder.setSelectionRange(selectionStart, selectionEnd);
        mMatrix.setScale(mScale, mScale);
        mMatrix.postTranslate(mTranslationX, mTranslationY);
        mCursorAnchorInfoBuilder.setMatrix(mMatrix);
        if (mHasInsertionMarker) {
            mCursorAnchorInfoBuilder.setInsertionMarkerLocation(
                    mInsertionMarkerHorizontal,
                    mInsertionMarkerTop,
                    mInsertionMarkerBottom,
                    mInsertionMarkerBottom,
                    mIsInsertionMarkerVisible ? CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION :
                            CursorAnchorInfo.FLAG_HAS_INVISIBLE_REGION);
        }
        mLastCursorAnchorInfo = mCursorAnchorInfoBuilder.build();
    }

    if (mInputMethodManagerWrapper != null) {
        mInputMethodManagerWrapper.updateCursorAnchorInfo(view, mLastCursorAnchorInfo);
    }
    mHasPendingImmediateRequest = false;
}
 
public RealWrapper(@Nonnull final CursorAnchorInfo info) {
    mInstance = info;
}
 
源代码10 项目: android_9.0.0_r45   文件: InputMethodService.java
/**
 * Called when the application has reported a new location of its text insertion point and
 * characters in the composition string.  This is only called if explicitly requested by the
 * input method. The default implementation does nothing.
 * @param cursorAnchorInfo The positional information of the text insertion point and the
 * composition string.
 */
public void onUpdateCursorAnchorInfo(CursorAnchorInfo cursorAnchorInfo) {
    // Intentionally empty
}
 
 类所在包
 同包方法