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


Java AccessibilityRecordCompat.setSource方法代碼示例

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


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

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

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

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

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

示例5: createEventForChild

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 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

示例6: getEventForItem

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
private AccessibilityEvent getEventForItem(T item, int eventType) {
        final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
        final int virtualDescendantId = getIdForItem(item);
// Ensure the client has good defaults.
        event.setEnabled(true);
// Allow the client to populate the event.
        populateEventForItem(item, 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.setClassName(item.getClass().getName());
        event.setPackageName(mParentView.getContext().getPackageName());
        record.setSource(mParentView, virtualDescendantId);
        return event;
    }
 
開發者ID:dgrigutsch,項目名稱:HoloDatePickerDialog,代碼行數:19,代碼來源:TouchExplorationHelper.java

示例7: getEventForItem

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
private AccessibilityEvent getEventForItem(
    T item,
    int eventType) {
  final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
  final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
  final int virtualDescendantId = getIdForItem(item);

  // Ensure the client has good defaults.
  event.setEnabled(true);

  // Allow the client to populate the event.
  populateEventForItem(item, 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.setClassName(item.getClass().getName());
  event.setPackageName(mParentView.getContext().getPackageName());
  record.setSource(mParentView, virtualDescendantId);

  return event;
}
 
開發者ID:cdeange,項目名稱:uwaterloo-api,代碼行數:26,代碼來源:TouchExplorationHelper.java

示例8: getEventForItem

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
private AccessibilityEvent getEventForItem(T item, int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    final int virtualDescendantId = getIdForItem(item);

    // Ensure the client has good defaults.
    event.setEnabled(true);

    // Allow the client to populate the event.
    populateEventForItem(item, 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.setClassName(item.getClass().getName());
    event.setPackageName(mParentView.getContext().getPackageName());
    record.setSource(mParentView, virtualDescendantId);

    return event;
}
 
開發者ID:restorer,項目名稱:gloomy-dungeons-2,代碼行數:24,代碼來源:TouchExplorationHelper.java

示例9: getEventForItem

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
private AccessibilityEvent getEventForItem(T item, int eventType) {
	final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
	final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
	final int virtualDescendantId = getIdForItem(item);

	// Ensure the client has good defaults.
	event.setEnabled(true);

	// Allow the client to populate the event.
	populateEventForItem(item, 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.setClassName(item.getClass().getName());
	event.setPackageName(mParentView.getContext().getPackageName());
	record.setSource(mParentView, virtualDescendantId);

	return event;
}
 
開發者ID:RedInput,項目名稱:DateTimePickerCompat,代碼行數:24,代碼來源:TouchExplorationHelper.java

示例10: sendAccessibilityEventForVirtualText

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
private void sendAccessibilityEventForVirtualText(int eventType) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        ViewCompat.onInitializeAccessibilityEvent(getInputText(), event);
        ViewCompat.onPopulateAccessibilityEvent(getInputText(), event);
        record.setSource(mNumberPicker, VIRTUAL_VIEW_ID_INPUT);

        ViewParentCompat.requestSendAccessibilityEvent(mNumberPicker, mNumberPicker, event);
    }
}
 
開發者ID:h6ah4i,項目名稱:android-numberpickercompat,代碼行數:13,代碼來源:AccessibilityNodeProviderImpl.java

示例11: sendAccessibilityEventForVirtualButton

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
private void sendAccessibilityEventForVirtualButton(int virtualViewId, int eventType,
                                                    String text) {
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
        event.setPackageName(getContext().getPackageName());
        record.setClassName(Button.class.getName());
        record.getText().add(text);
        record.setEnabled(isEnabled());
        record.setSource(mNumberPicker, virtualViewId);

        ViewParentCompat.requestSendAccessibilityEvent(mNumberPicker, mNumberPicker, event);
    }
}
 
開發者ID:h6ah4i,項目名稱:android-numberpickercompat,代碼行數:16,代碼來源:AccessibilityNodeProviderImpl.java

示例12: createAccessibilityEvent

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
/**
 * Creates and populates an {@link AccessibilityEvent} for the specified key
 * and event type.
 *
 * @param key A key on the host keyboard view.
 * @param eventType The event type to create.
 * @return A populated {@link AccessibilityEvent} for the key.
 * @see AccessibilityEvent
 */
public AccessibilityEvent createAccessibilityEvent(final Key key, final int eventType) {
    final int virtualViewId = getVirtualViewIdOf(key);
    final String keyDescription = getKeyDescription(key);
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    event.setPackageName(mKeyboardView.getContext().getPackageName());
    event.setClassName(key.getClass().getName());
    event.setContentDescription(keyDescription);
    event.setEnabled(true);
    final AccessibilityRecordCompat record = AccessibilityEventCompat.asRecord(event);
    record.setSource(mKeyboardView, virtualViewId);
    return event;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:22,代碼來源:KeyboardAccessibilityNodeProvider.java

示例13: sendAccessibilityEventForVirtualText

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
private void sendAccessibilityEventForVirtualText(int eventType) {
    //if (AccessibilityManager.getInstance(mContext).isEnabled()) {
    if (accessibilityManager != null && accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        mInputText.onInitializeAccessibilityEvent(event);
        mInputText.onPopulateAccessibilityEvent(event);
        AccessibilityRecordCompat.setSource(event, NumberPicker.this, VIRTUAL_VIEW_ID_INPUT);
        // event.setSource(NumberPicker.this, VIRTUAL_VIEW_ID_INPUT);
        requestSendAccessibilityEvent(NumberPicker.this, event);
    }
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:12,代碼來源:NumberPicker.java

示例14: sendAccessibilityEventForVirtualButton

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
private void sendAccessibilityEventForVirtualButton(int virtualViewId, int eventType,
                                                    String text) {
    //if (AccessibilityManager.getInstance(mContext).isEnabled()) {
    if (accessibilityManager != null && accessibilityManager.isEnabled()) {
        AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
        event.setClassName(Button.class.getName());
        event.setPackageName(getContext().getPackageName());
        event.getText().add(text);
        event.setEnabled(NumberPicker.this.isEnabled());
        AccessibilityRecordCompat.setSource(event, NumberPicker.this, virtualViewId);
        //event.setSource(NumberPicker.this, virtualViewId);
        requestSendAccessibilityEvent(NumberPicker.this, event);
    }
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:15,代碼來源:NumberPicker.java

示例15: getEventForRoot

import android.support.v4.view.accessibility.AccessibilityRecordCompat; //導入方法依賴的package包/類
private AccessibilityEvent getEventForRoot(int eventType) {
    final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
    mHost.onInitializeAccessibilityEvent(event);

    final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
    record.setSource(mHost, ROOT_ID);

    return event;
}
 
開發者ID:google,項目名稱:brailleback,代碼行數:10,代碼來源:ExploreByTouchHelper.java


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