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


Java AccessibilityEvent.setFromIndex方法代码示例

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


在下文中一共展示了AccessibilityEvent.setFromIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onInitializeAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) {
        event.setFromIndex(0);
        event.setToIndex(0);
    }
}
 
开发者ID:LingjuAI,项目名称:AssistantBySDK,代码行数:9,代码来源:YearPickerView.java

示例3: 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

示例4: onInitializeAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setScrollable(isScrollableForAccessibility());
    View selectedView = getSelectedView();
    if (selectedView != null) {
        event.setEnabled(selectedView.isEnabled());
    }
    event.setCurrentItemIndex(getSelectedItemPosition());
    event.setFromIndex(getFirstVisiblePosition());
    event.setToIndex(getLastVisiblePosition());
    event.setItemCount(getCount());
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:14,代码来源:IcsAdapterView.java

示例5: onInitializeAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@TargetApi(14)
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    event.setClassName(AdapterView.class.getName());
    event.setScrollable(isScrollableForAccessibility());
    View selectedView = getSelectedView();
    if (selectedView != null) {
        event.setEnabled(selectedView.isEnabled());
    }
    event.setCurrentItemIndex(getSelectedItemPosition());
    event.setFromIndex(getFirstVisiblePosition());
    event.setToIndex(getLastVisiblePosition());
    event.setItemCount(getCount());
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:15,代码来源:AdapterView.java

示例6: onInitializeAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@TargetApi(14)
@Override
public void onInitializeAccessibilityEvent( AccessibilityEvent event ) {
	super.onInitializeAccessibilityEvent( event );
	event.setClassName( AdapterView.class.getName() );
	event.setScrollable( isScrollableForAccessibility() );
	View selectedView = getSelectedView();
	if ( selectedView != null ) {
		event.setEnabled( selectedView.isEnabled() );
	}
	event.setCurrentItemIndex( getSelectedItemPosition() );
	event.setFromIndex( getFirstVisiblePosition() );
	event.setToIndex( getLastVisiblePosition() );
	event.setItemCount( getCount() );
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:16,代码来源:AdapterView.java

示例7: onInitializeAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
public void onInitializeAccessibilityEvent(AccessibilityEvent paramAccessibilityEvent) {
	super.onInitializeAccessibilityEvent(paramAccessibilityEvent);
	paramAccessibilityEvent.setScrollable(isScrollableForAccessibility());
	View localView = getSelectedView();
	if (localView != null)
		paramAccessibilityEvent.setEnabled(localView.isEnabled());
	paramAccessibilityEvent.setCurrentItemIndex(getSelectedItemPosition());
	paramAccessibilityEvent.setFromIndex(getFirstVisiblePosition());
	paramAccessibilityEvent.setToIndex(getLastVisiblePosition());
	paramAccessibilityEvent.setItemCount(getCount());
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:12,代码来源:AdapterView.java

示例8: onInitializeAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);
    if (event.getEventType() == 4096) {
        event.setFromIndex(0);
        event.setToIndex(0);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:YearPickerView.java

示例9: onInitializeAccessibilityEvent

import android.view.accessibility.AccessibilityEvent; //导入方法依赖的package包/类
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(event);

    // Decoration-only headers should not count as an item for accessibility, adjust the
    // accessibility event to account for that.
    final int numberOfHeaders = mSticky != null ? 1 : 0;
    event.setItemCount(event.getItemCount() - numberOfHeaders);
    event.setFromIndex(Math.max(event.getFromIndex() - numberOfHeaders, 0));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        event.setToIndex(Math.max(event.getToIndex() - numberOfHeaders, 0));
    }
}
 
开发者ID:Trumeet,项目名称:SetupWizardLibCompat,代码行数:14,代码来源:StickyHeaderListView.java

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