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


Java AccessibilityEventCompat.asRecord方法代碼示例

本文整理匯總了Java中android.support.v4.view.accessibility.AccessibilityEventCompat.asRecord方法的典型用法代碼示例。如果您正苦於以下問題:Java AccessibilityEventCompat.asRecord方法的具體用法?Java AccessibilityEventCompat.asRecord怎麽用?Java AccessibilityEventCompat.asRecord使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.view.accessibility.AccessibilityEventCompat的用法示例。


在下文中一共展示了AccessibilityEventCompat.asRecord方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

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

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

示例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:pooyafaroka,項目名稱:PlusGram,代碼行數:28,代碼來源:RecyclerView.java

示例5: makeAnnouncement

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的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

示例6: createEventForChild

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的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 createEventForChild(int virtualViewId, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setEnabled(true);
    event.setClassName(DEFAULT_CLASS_NAME);

    // Allow the client to populate the event.
    onPopulateEventForVirtualView(virtualViewId, event);

    // Make sure the developer is following the rules.
    if (event.getText().isEmpty() && (event.getContentDescription() == null)) {
        throw new RuntimeException("Callbacks must add text or a content description in "
                + "populateEventForVirtualViewId()");
    }

    // Don't allow the client to override these properties.
    event.setPackageName(mView.getContext().getPackageName());

    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setSource(mView, virtualViewId);

    return event;
}
 
開發者ID:bestarandyan,項目名稱:ShoppingMall,代碼行數:33,代碼來源:ExploreByTouchHelper.java

示例7: onInitializeAccessibilityEvent

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的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

示例8: onInitializeAccessibilityEvent

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的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

示例9: onInitializeAccessibilityEvent

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的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

示例10: getEventForVirtualViewId

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的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

示例11: format

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的package包/類
@Override
public boolean format(AccessibilityEvent event, TalkBackService context, Utterance utterance) {
    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    final AccessibilityNodeInfoCompat source = record.getSource();
    if (source == null) return false;

    CharSequence text = format(context, source, event);
    if (TextUtils.isEmpty(text)) return false;

    utterance.addSpoken(text);
    utterance.getMetadata().putInt(Utterance.KEY_UTTERANCE_GROUP,
            SpeechController.UTTERANCE_GROUP_SEEK_PROGRESS);
    utterance.addSpokenFlag(
            FeedbackItem.FLAG_CLEAR_QUEUED_UTTERANCES_WITH_SAME_UTTERANCE_GROUP);
    utterance.getMetadata().putInt(Utterance.KEY_METADATA_QUEUING,
            SpeechController.QUEUE_MODE_UNINTERRUPTIBLE);
    return true;
}
 
開發者ID:google,項目名稱:talkback,代碼行數:19,代碼來源:RuleSeekBar.java

示例12: onInitializeAccessibilityEvent

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的package包/類
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(ViewPager.class.getName());
    AccessibilityRecordCompat recordCompat = AccessibilityEventCompat.asRecord(event);
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == 4096 && ViewPager.this.mAdapter != null) {
        recordCompat.setItemCount(ViewPager.this.mAdapter.getCount());
        recordCompat.setFromIndex(ViewPager.this.mCurItem);
        recordCompat.setToIndex(ViewPager.this.mCurItem);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:ViewPager.java

示例13: onInitializeAccessibilityEvent

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的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);
    record.setItemCount(mApps.getNumFilteredApps());
    record.setFromIndex(Math.max(0,
            record.getFromIndex() - getRowsNotForAccessibility(record.getFromIndex())));
    record.setToIndex(Math.max(0,
            record.getToIndex() - getRowsNotForAccessibility(record.getToIndex())));
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:15,代碼來源:AllAppsGridAdapter.java

示例14: 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);
        record.setFromIndex(getPosition(getFirstChild()));
        record.setToIndex(getPosition(getLastChild()));
    }
}
 
開發者ID:xieyangxuejun,項目名稱:Views,代碼行數:10,代碼來源:DiscreteScrollLayoutManager.java

示例15: onInitializeAccessibilityEvent

import android.support.v4.view.accessibility.AccessibilityEventCompat; //導入方法依賴的package包/類
@Override
public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
    super.onInitializeAccessibilityEvent(host, event);
    event.setClassName(YViewPagerNew.class.getName());
    final AccessibilityRecordCompat recordCompat =
            AccessibilityEventCompat.asRecord(event);
    recordCompat.setScrollable(canScroll());
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED
            && mAdapter != null) {
        recordCompat.setItemCount(getAdapterCount());
        recordCompat.setFromIndex(mCurItem);
        recordCompat.setToIndex(mCurItem);
    }
}
 
開發者ID:youngkaaa,項目名稱:YViewPagerDemo,代碼行數:15,代碼來源:YViewPagerNew.java


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