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


Java AccessibilityEventCompat类代码示例

本文整理汇总了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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DirectionalViewpager.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DirectionalViewpager.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:BaseViewPager.java

示例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());
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:28,代码来源:RecyclerView.java

示例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);
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:23,代码来源:StaggeredGridLayoutManager.java

示例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;
}
 
开发者ID:youngkaaa,项目名称:YViewPagerDemo,代码行数:23,代码来源:YViewPager.java

示例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;
}
 
开发者ID:youngkaaa,项目名称:YViewPagerDemo,代码行数:23,代码来源:YViewPagerNew.java

示例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;
}
 
开发者ID:youngkaaa,项目名称:YViewPagerDemo,代码行数:23,代码来源:YViewPagerOrigin.java

示例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;
}
 
开发者ID:SimonCherryGZ,项目名称:JewelryUI,代码行数:23,代码来源:ViewPager.java

示例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;
}
 
开发者ID:fengshihao,项目名称:WebPager,代码行数:23,代码来源:CustomViewPager.java

示例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);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:StaggeredGridLayoutManager.java

示例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);
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:21,代码来源:AbsHListView.java

示例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());
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:28,代码来源:RecyclerView.java

示例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);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:41,代码来源:AccessibilityUtils.java


注:本文中的android.support.v4.view.accessibility.AccessibilityEventCompat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。