本文整理匯總了Java中android.support.v4.view.accessibility.AccessibilityEventCompat類的典型用法代碼示例。如果您正苦於以下問題:Java AccessibilityEventCompat類的具體用法?Java AccessibilityEventCompat怎麽用?Java AccessibilityEventCompat使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AccessibilityEventCompat類屬於android.support.v4.view.accessibility包,在下文中一共展示了AccessibilityEventCompat類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dispatchPopulateAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
// Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
final ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem &&
child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return false;
}
示例2: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(host, event);
event.setClassName(DirectionalViewpager.class.getName());
AccessibilityRecordCompat recordCompat = null;
if (isHorizontal()) {
recordCompat =
AccessibilityEventCompat.asRecord(event);
} else {
recordCompat = AccessibilityRecordCompat.obtain();
}
recordCompat.setScrollable(canScroll());
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
&& mAdapter != null) {
recordCompat.setItemCount(mAdapter.getCount());
recordCompat.setFromIndex(mCurItem);
recordCompat.setToIndex(mCurItem);
}
}
示例3: dispatchPopulateAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
// Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
final ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem
&& child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return false;
}
示例4: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
/**
* Called by the accessibility delegate to initialize an accessibility event.
* <p>
* Default implementation adds item count and scroll information to the event.
*
* @param recycler The Recycler that can be used to convert view positions into adapter
* positions
* @param state The current state of RecyclerView
* @param event The event instance to initialize
* @see View#onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent)
*/
public void onInitializeAccessibilityEvent(Recycler recycler, State state,
AccessibilityEvent event) {
final AccessibilityRecordCompat record = AccessibilityEventCompat
.asRecord(event);
if (mRecyclerView == null || record == null) {
return;
}
record.setScrollable(ViewCompat.canScrollVertically(mRecyclerView, 1)
|| ViewCompat.canScrollVertically(mRecyclerView, -1)
|| ViewCompat.canScrollHorizontally(mRecyclerView, -1)
|| ViewCompat.canScrollHorizontally(mRecyclerView, 1));
if (mRecyclerView.mAdapter != null) {
record.setItemCount(mRecyclerView.mAdapter.getItemCount());
}
}
示例5: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
if (getChildCount() > 0) {
final AccessibilityRecordCompat record = AccessibilityEventCompat
.asRecord(event);
final View start = findFirstVisibleItemClosestToStart(false, true);
final View end = findFirstVisibleItemClosestToEnd(false, true);
if (start == null || end == null) {
return;
}
final int startPos = getPosition(start);
final int endPos = getPosition(end);
if (startPos < endPos) {
record.setFromIndex(startPos);
record.setToIndex(endPos);
} else {
record.setFromIndex(endPos);
record.setToIndex(startPos);
}
}
}
示例6: dispatchPopulateAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
// Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
final YViewPager.ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem
&& child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return false;
}
示例7: dispatchPopulateAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
// Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
final YViewPagerNew.ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem
&& child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return false;
}
示例8: dispatchPopulateAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
// Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
final YViewPagerOrigin.ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem
&& child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return false;
}
示例9: dispatchPopulateAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
// Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
final ViewPager.ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem
&& child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return false;
}
示例10: dispatchPopulateAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// Dispatch scroll events from this ViewPager.
if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
return super.dispatchPopulateAccessibilityEvent(event);
}
// Dispatch all other accessibility events from the current page.
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
final ItemInfo ii = infoForChild(child);
if (ii != null && ii.position == mCurItem
&& child.dispatchPopulateAccessibilityEvent(event)) {
return true;
}
}
}
return false;
}
示例11: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
if (getChildCount() > 0) {
AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
View start = findFirstVisibleItemClosestToStart(false, true);
View end = findFirstVisibleItemClosestToEnd(false, true);
if (start != null && end != null) {
int startPos = getPosition(start);
int endPos = getPosition(end);
if (startPos < endPos) {
record.setFromIndex(startPos);
record.setToIndex(endPos);
return;
}
record.setFromIndex(endPos);
record.setToIndex(startPos);
}
}
}
示例12: sendAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
@Override
public void sendAccessibilityEvent(int eventType) {
// Since this class calls onScrollChanged even if the mFirstPosition and
// the
// child count have not changed we will avoid sending duplicate
// accessibility
// events.
if (eventType == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
final int firstVisiblePosition = getFirstVisiblePosition();
final int lastVisiblePosition = getLastVisiblePosition();
if (mLastAccessibilityScrollEventFromIndex == firstVisiblePosition
&& mLastAccessibilityScrollEventToIndex == lastVisiblePosition) {
return;
} else {
mLastAccessibilityScrollEventFromIndex = firstVisiblePosition;
mLastAccessibilityScrollEventToIndex = lastVisiblePosition;
}
}
super.sendAccessibilityEvent(eventType);
}
示例13: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
/**
* Called by the accessibility delegate to initialize an accessibility event.
* <p>
* Default implementation adds item count and scroll information to the event.
*
* @param recycler The Recycler that can be used to convert view positions into adapter
* positions
* @param state The current state of RecyclerView
* @param event The event instance to initialize
* @see View#onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent)
*/
public void onInitializeAccessibilityEvent(Recycler recycler, State state,
AccessibilityEvent event) {
final AccessibilityRecordCompat record = AccessibilityEventCompat
.asRecord(event);
if (mRecyclerView == null || record == null) {
return;
}
record.setScrollable(ViewCompat.canScrollVertically(mRecyclerView, 1)
|| ViewCompat.canScrollVertically(mRecyclerView, -1)
|| ViewCompat.canScrollHorizontally(mRecyclerView, -1)
|| ViewCompat.canScrollHorizontally(mRecyclerView, 1));
if (mRecyclerView.mAdapter != null) {
record.setItemCount(mRecyclerView.mAdapter.getItemCount());
}
}
示例14: performActionForKey
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
/**
* Performs the specified accessibility action for the given key.
*
* @param key The on which to perform the action.
* @param action The action to perform.
* @return The result of performing the action, or false if the action is not supported.
*/
boolean performActionForKey(final Key key, final int action) {
switch (action) {
case AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS:
mAccessibilityFocusedView = getVirtualViewIdOf(key);
sendAccessibilityEventForKey(
key, AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
return true;
case AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS:
mAccessibilityFocusedView = UNDEFINED;
sendAccessibilityEventForKey(
key, AccessibilityEventCompat.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
return true;
case AccessibilityNodeInfoCompat.ACTION_CLICK:
sendAccessibilityEventForKey(key, AccessibilityEvent.TYPE_VIEW_CLICKED);
mDelegate.performClickOn(key);
return true;
case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK:
sendAccessibilityEventForKey(key, AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
mDelegate.performLongClickOn(key);
return true;
default:
return false;
}
}
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:32,代碼來源:KeyboardAccessibilityNodeProvider.java
示例15: announceForAccessibility
import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入依賴的package包/類
/**
* Sends the specified text to the {@link AccessibilityManager} to be
* spoken.
*
* @param view The source view.
* @param text The text to speak.
*/
public void announceForAccessibility(final View view, final CharSequence text) {
if (!mAccessibilityManager.isEnabled()) {
Log.e(TAG, "Attempted to speak when accessibility was disabled!");
return;
}
// The following is a hack to avoid using the heavy-weight TextToSpeech
// class. Instead, we're just forcing a fake AccessibilityEvent into
// the screen reader to make it speak.
final AccessibilityEvent event = AccessibilityEvent.obtain();
event.setPackageName(PACKAGE);
event.setClassName(CLASS);
event.setEventTime(SystemClock.uptimeMillis());
event.setEnabled(true);
event.getText().add(text);
// Platforms starting at SDK version 16 (Build.VERSION_CODES.JELLY_BEAN) should use
// announce events.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
event.setEventType(AccessibilityEventCompat.TYPE_ANNOUNCEMENT);
} else {
event.setEventType(AccessibilityEvent.TYPE_VIEW_FOCUSED);
}
final ViewParent viewParent = view.getParent();
if ((viewParent == null) || !(viewParent instanceof ViewGroup)) {
Log.e(TAG, "Failed to obtain ViewParent in announceForAccessibility");
return;
}
viewParent.requestSendAccessibilityEvent(view, event);
}