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


Java AccessibilityRecordCompat類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:DirectionalViewpager.java

示例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());
    }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:28,代碼來源:RecyclerView.java

示例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);
        }
    }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:23,代碼來源:StaggeredGridLayoutManager.java

示例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);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:StaggeredGridLayoutManager.java

示例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());
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:28,代碼來源:RecyclerView.java

示例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;
}
 
開發者ID:google,項目名稱:brailleback,代碼行數:35,代碼來源:ExploreByTouchHelper.java

示例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);
    }
}
 
開發者ID:andela-kogunde,項目名稱:CheckSmarter,代碼行數:24,代碼來源:AccessibilityUtils.java

示例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;
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:20,代碼來源:RecyclerView.java

示例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;
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:22,代碼來源:NestedScrollView.java

示例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());
}
 
開發者ID:RunasSudo,項目名稱:FLauncher,代碼行數:17,代碼來源:AllAppsGridAdapter.java

示例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);
    }
}
 
開發者ID:jameliu,項目名稱:Camera2,代碼行數:23,代碼來源:AccessibilityUtils.java

示例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;
}
 
開發者ID:google,項目名稱:talkback,代碼行數:34,代碼來源:ExploreByTouchHelper.java

示例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;
}
 
開發者ID:google,項目名稱:talkback,代碼行數:19,代碼來源:ProgressBarFormatter.java

示例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;
    }
}
 
開發者ID:google,項目名稱:talkback,代碼行數:25,代碼來源:LiveViewFormatter.java

示例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;
        }
    }
}
 
開發者ID:google,項目名稱:talkback,代碼行數:20,代碼來源:ProcessorFocusAndSingleTap.java


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