当前位置: 首页>>代码示例>>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;未经允许,请勿转载。