本文整理汇总了Java中android.support.v4.view.accessibility.AccessibilityRecordCompat类的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityRecordCompat类的具体用法?Java AccessibilityRecordCompat怎么用?Java AccessibilityRecordCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AccessibilityRecordCompat类属于android.support.v4.view.accessibility包,在下文中一共展示了AccessibilityRecordCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的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);
}
}
示例2: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的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());
}
}
示例3: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的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);
}
}
}
示例4: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的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);
}
}
}
示例5: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的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());
}
}
示例6: getEventForVirtualViewId
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
/**
* Constructs and returns an {@link AccessibilityEvent} populated with
* information about the specified item.
*
* @param virtualViewId The virtual view id for the item for which to
* construct an event.
* @param eventType The type of event to construct.
* @return An {@link AccessibilityEvent} populated with information about
* the specified item.
*/
private AccessibilityEvent getEventForVirtualViewId(int virtualViewId, int eventType) {
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
// Ensure the client has good defaults.
event.setEnabled(true);
event.setClassName(mHost.getClass().getName() + DEFAULT_CLASS_NAME);
// Allow the client to populate the event.
populateEventForVirtualViewId(virtualViewId, event);
if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) {
throw new RuntimeException(
"You must add text or a content description in populateEventForItem()");
}
// Don't allow the client to override these properties.
event.setPackageName(mHost.getContext().getPackageName());
// Virtual view hierarchies are only supported in API 16+.
final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
record.setSource(mHost, virtualViewId);
return event;
}
示例7: makeAnnouncement
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
public static void makeAnnouncement(View view, CharSequence announcement) {
if (view == null)
return;
if (SUtils.isApi_16_OrHigher()) {
view.announceForAccessibility(announcement);
} else {
// For API 15 and earlier, we need to construct an accessibility event
Context ctx = view.getContext();
AccessibilityManager am = (AccessibilityManager) ctx.getSystemService(
Context.ACCESSIBILITY_SERVICE);
if (!am.isEnabled()) return;
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
AccessibilityRecordCompat arc = AccessibilityEventCompat.asRecord(event);
arc.setSource(view);
event.setClassName(view.getClass().getName());
event.setPackageName(view.getContext().getPackageName());
event.setEnabled(view.isEnabled());
event.getText().add(announcement);
am.sendAccessibilityEvent(event);
}
}
示例8: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
public void onInitializeAccessibilityEvent(AccessibilityEvent paramAccessibilityEvent)
{
int i = 1;
AccessibilityRecordCompat localAccessibilityRecordCompat = AccessibilityEventCompat.asRecord(paramAccessibilityEvent);
if (this.mRecyclerView == null) {
return;
}
if ((ViewCompat.canScrollVertically(this.mRecyclerView, i)) || (ViewCompat.canScrollVertically(this.mRecyclerView, -1)) || (ViewCompat.canScrollHorizontally(this.mRecyclerView, -1)) || (ViewCompat.canScrollHorizontally(this.mRecyclerView, i))) {}
for (;;)
{
localAccessibilityRecordCompat.setScrollable(i);
if (this.mRecyclerView.mAdapter == null) {
break;
}
localAccessibilityRecordCompat.setItemCount(this.mRecyclerView.mAdapter.getItemCount());
return;
int j = 0;
}
}
示例9: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
public final void onInitializeAccessibilityEvent(View paramView, AccessibilityEvent paramAccessibilityEvent)
{
super.onInitializeAccessibilityEvent(paramView, paramAccessibilityEvent);
NestedScrollView localNestedScrollView = (NestedScrollView)paramView;
paramAccessibilityEvent.setClassName(ScrollView.class.getName());
AccessibilityRecordCompat localAccessibilityRecordCompat = AccessibilityEventCompat.asRecord(paramAccessibilityEvent);
if (localNestedScrollView.getScrollRange() > 0) {}
for (boolean bool = true;; bool = false)
{
localAccessibilityRecordCompat.setScrollable(bool);
int i = localNestedScrollView.getScrollX();
AccessibilityRecordCompat.IMPL.setScrollX(localAccessibilityRecordCompat.mRecord, i);
int j = localNestedScrollView.getScrollY();
AccessibilityRecordCompat.IMPL.setScrollY(localAccessibilityRecordCompat.mRecord, j);
int k = localNestedScrollView.getScrollX();
AccessibilityRecordCompat.IMPL.setMaxScrollX(localAccessibilityRecordCompat.mRecord, k);
int m = localNestedScrollView.getScrollRange();
AccessibilityRecordCompat.IMPL.setMaxScrollY(localAccessibilityRecordCompat.mRecord, m);
return;
}
}
示例10: onInitializeAccessibilityEvent
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
@Override
public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
super.onInitializeAccessibilityEvent(event);
// Ensure that we only report the number apps for accessibility not including other
// adapter views
final AccessibilityRecordCompat record = AccessibilityEventCompat
.asRecord(event);
// count the number of SECTION_BREAK_VIEW_TYPE that is wrongfully
// initialized as a node (also a row) for talk back.
int numEmptyNode = getEmptyRowForAccessibility(-1 /* no view type */);
record.setFromIndex(event.getFromIndex() - numEmptyNode);
record.setToIndex(event.getToIndex() - numEmptyNode);
record.setItemCount(mApps.getNumFilteredApps());
}
示例11: makeAnnouncement
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
public static void makeAnnouncement(View view, CharSequence announcement) {
if (view == null)
return;
if (ApiHelper.HAS_ANNOUNCE_FOR_ACCESSIBILITY) {
view.announceForAccessibility(announcement);
} else {
// For API 15 and earlier, we need to construct an accessibility event
Context ctx = view.getContext();
AccessibilityManager am = (AccessibilityManager) ctx.getSystemService(
Context.ACCESSIBILITY_SERVICE);
if (!am.isEnabled()) return;
AccessibilityEvent event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
AccessibilityRecordCompat arc = new AccessibilityRecordCompat(event);
arc.setSource(view);
event.setClassName(view.getClass().getName());
event.setPackageName(view.getContext().getPackageName());
event.setEnabled(view.isEnabled());
event.getText().add(announcement);
am.sendAccessibilityEvent(event);
}
}
示例12: getEventForVirtualViewId
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
/**
* Constructs and returns an {@link AccessibilityEvent} populated with
* information about the specified item.
*
* @param virtualViewId The virtual view id for the item for which to
* construct an event.
* @param eventType The type of event to construct.
* @return An {@link AccessibilityEvent} populated with information about
* the specified item.
*/
private AccessibilityEvent getEventForVirtualViewId(int virtualViewId, int eventType) {
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
// Ensure the client has good defaults.
event.setEnabled(true);
event.setClassName(mHost.getClass().getName() + DEFAULT_CLASS_NAME);
// Allow the client to populate the event.
populateEventForVirtualViewId(virtualViewId, event);
if (event.getText().isEmpty() && TextUtils.isEmpty(event.getContentDescription())) {
throw new RuntimeException(
"You must add text or a content description in populateEventForItem()");
}
// Don't allow the client to override these properties.
event.setPackageName(mHost.getContext().getPackageName());
final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
record.setSource(mHost, virtualViewId);
return event;
}
示例13: shouldDropEvent
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
private boolean shouldDropEvent(AccessibilityEvent event) {
final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
final AccessibilityNodeInfoCompat source = record.getSource();
// Don't drop if we're on pre-ICS or the event was generated (e.g.
// missing a node).
if (source == null) {
return false;
}
// Don't drop if the node is currently focused or accessibility focused.
if (source.isFocused() || source.isAccessibilityFocused()) {
return false;
}
// Don't drop if the node was recently explored.
return true;
}
示例14: accept
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
@Override
public boolean accept(AccessibilityEvent event, TalkBackService context) {
if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED) return false;
AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
AccessibilityNodeInfoCompat node = record.getSource();
if (node == null) {
return false;
}
int liveRegion = node.getLiveRegion();
node.recycle();
switch (liveRegion) {
case View.ACCESSIBILITY_LIVE_REGION_POLITE:
return true;
case View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE:
return true;
case View.ACCESSIBILITY_LIVE_REGION_NONE:
return false;
default:
return false;
}
}
示例15: tryFocusCachedRecord
import android.support.v4.view.accessibility.AccessibilityRecordCompat; //导入依赖的package包/类
private void tryFocusCachedRecord() {
if (mCachedPotentiallyFocusableRecordQueue.isEmpty()) {
return;
}
Iterator<Pair<AccessibilityRecordCompat, Integer>> iterator =
mCachedPotentiallyFocusableRecordQueue.descendingIterator();
while(iterator.hasNext()) {
Pair<AccessibilityRecordCompat, Integer> focusableRecord = iterator.next();
AccessibilityRecordCompat record = focusableRecord.first;
int eventType = focusableRecord.second;
if (setFocusOnView(record,
eventType == AccessibilityEvent.TYPE_VIEW_FOCUSED)) {
emptyCachedPotentialFocusQueue();
return;
}
}
}