當前位置: 首頁>>代碼示例>>Java>>正文


Java AccessibilityEvent.setAddedCount方法代碼示例

本文整理匯總了Java中android.view.accessibility.AccessibilityEvent.setAddedCount方法的典型用法代碼示例。如果您正苦於以下問題:Java AccessibilityEvent.setAddedCount方法的具體用法?Java AccessibilityEvent.setAddedCount怎麽用?Java AccessibilityEvent.setAddedCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.accessibility.AccessibilityEvent的用法示例。


在下文中一共展示了AccessibilityEvent.setAddedCount方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
public void run() {
	synchronized (mAccessibilityLock) {
		if (mCodeMatcher == null) {
			mCodeMatcher = mControlCodes.matcher(mAccessibilityBuffer.toString());
		} else {
			mCodeMatcher.reset(mAccessibilityBuffer.toString());
		}

		// Strip all control codes out.
		mAccessibilityBuffer.setLength(0);
		while (mCodeMatcher.find()) {
			mCodeMatcher.appendReplacement(mAccessibilityBuffer, " ");
		}

		// Apply Backspaces using backspace character sequence
		int i = mAccessibilityBuffer.indexOf(BACKSPACE_CODE);
		while (i != -1) {
			mAccessibilityBuffer.replace(i == 0 ? 0 : i - 1,
					i + BACKSPACE_CODE.length(), "");
			i = mAccessibilityBuffer.indexOf(BACKSPACE_CODE);
		}

		if (mAccessibilityBuffer.length() > 0) {
			AccessibilityEvent event = AccessibilityEvent.obtain(
					AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
			event.setFromIndex(0);
			event.setAddedCount(mAccessibilityBuffer.length());
			event.getText().add(mAccessibilityBuffer);

			sendAccessibilityEventUnchecked(event);
			mAccessibilityBuffer.setLength(0);
		}
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:35,代碼來源:TerminalView.java

示例2: sendAccessibilityEventUnchecked

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
@Override
public void sendAccessibilityEventUnchecked(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED) {
        // Since we're replacing the text every time we add or remove a
        // character, only read the difference. (issue 5337550)
        final int added = event.getAddedCount();
        final int removed = event.getRemovedCount();
        final int length = event.getBeforeText().length();
        if (added > removed) {
            event.setRemovedCount(0);
            event.setAddedCount(1);
            event.setFromIndex(length);
        } else if (removed > added) {
            event.setRemovedCount(1);
            event.setAddedCount(0);
            event.setFromIndex(length - 1);
        } else {
            return;
        }
    } else if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
        // The parent EditText class lets tts read "edit box" when this View
        // has a focus, which
        // confuses users on app launch (issue 5275935).
        return;
    }
    super.sendAccessibilityEventUnchecked(event);
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:28,代碼來源:DigitsEditText.java

示例3: commitText

import android.view.accessibility.AccessibilityEvent; //導入方法依賴的package包/類
@Override
public boolean commitText(CharSequence text, int newCursorPosition) {
    Editable currentText = getText();
    if (currentText == null) return super.commitText(text, newCursorPosition);

    int selectionStart = Selection.getSelectionStart(currentText);
    int selectionEnd = Selection.getSelectionEnd(currentText);
    int autocompleteIndex = currentText.getSpanStart(mAutocompleteSpan);
    // If the text being committed is a single character that matches the next character
    // in the selection (assumed to be the autocomplete text), we only move the text
    // selection instead clearing the autocomplete text causing flickering as the
    // autocomplete text will appear once the next suggestions are received.
    //
    // To be confident that the selection is an autocomplete, we ensure the selection
    // is at least one character and the end of the selection is the end of the
    // currently entered text.
    if (newCursorPosition == 1 && selectionStart > 0 && selectionStart != selectionEnd
            && selectionEnd >= currentText.length()
            && autocompleteIndex == selectionStart
            && text.length() == 1) {
        currentText.getChars(selectionStart, selectionStart + 1, mTempSelectionChar, 0);
        if (mTempSelectionChar[0] == text.charAt(0)) {

            // Since the text isn't changing, TalkBack won't read out the typed characters.
            // To work around this, explicitly send an accessibility event. crbug.com/416595
            if (mAccessibilityManager != null && mAccessibilityManager.isEnabled()) {
                AccessibilityEvent event = AccessibilityEvent.obtain(
                        AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
                event.setFromIndex(selectionStart);
                event.setRemovedCount(0);
                event.setAddedCount(1);
                event.setBeforeText(currentText.toString().substring(0, selectionStart));
                sendAccessibilityEventUnchecked(event);
            }

            setAutocompleteText(
                    currentText.subSequence(0, selectionStart + 1),
                    currentText.subSequence(selectionStart + 1, selectionEnd));
            if (!mInBatchEditMode) {
                notifyAutocompleteTextStateChanged(false);
            }
            return true;
        }
    }

    boolean retVal = super.commitText(text, newCursorPosition);

    // Ensure the autocomplete span is removed if it is no longer valid after committing the
    // text.
    if (getText().getSpanStart(mAutocompleteSpan) >= 0) clearAutocompleteSpanIfInvalid();

    return retVal;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:54,代碼來源:UrlBar.java


注:本文中的android.view.accessibility.AccessibilityEvent.setAddedCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。