Java Code Examples for android.view.View#dispatchPopulateAccessibilityEvent()

The following examples show how to use android.view.View#dispatchPopulateAccessibilityEvent() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/** @hide */
@Override
public boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) {
    if (mTopToBottomLeftToRightSet == null) {
        mTopToBottomLeftToRightSet = new TreeSet<View>(new TopToBottomLeftToRightComparator());
    }

    // sort children top-to-bottom and left-to-right
    for (int i = 0, count = getChildCount(); i < count; i++) {
        mTopToBottomLeftToRightSet.add(getChildAt(i));
    }

    for (View view : mTopToBottomLeftToRightSet) {
        if (view.getVisibility() == View.VISIBLE
                && view.dispatchPopulateAccessibilityEvent(event)) {
            mTopToBottomLeftToRightSet.clear();
            return true;
        }
    }

    mTopToBottomLeftToRightSet.clear();
    return false;
}
 
Example 2
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this ViewPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem &&
                    child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 3
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this VerticalViewPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem &&
                    child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 4
Source Project: CoolViewPager   File: CoolViewPager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this ViewPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final CoolViewPager.ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem
                    && child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 5
@SuppressLint("WrongConstant")
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this SliderPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem
                    && child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 6
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this ViewPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem &&
                    child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 7
Source Project: ticdesign   File: VerticalViewPager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this ViewPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem &&
                    child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 8
Source Project: android-recipes-app   File: ViewPager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this ViewPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem &&
                    child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 9
Source Project: YViewPagerDemo   File: YViewPagerNew.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this ViewPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final YViewPagerNew.ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem
                    && child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 10
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this ViewPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem &&
                    child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 11
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    // Dispatch scroll events from this ViewPager.
    if (event.getEventType() == AccessibilityEventCompat.TYPE_VIEW_SCROLLED) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == VISIBLE) {
            final ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == mCurItem &&
                    child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }

    return false;
}
 
Example 12
Source Project: letv   File: ViewPager.java    License: Apache License 2.0 6 votes vote down vote up
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == 4096) {
        return super.dispatchPopulateAccessibilityEvent(event);
    }
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        if (child.getVisibility() == 0) {
            ItemInfo ii = infoForChild(child);
            if (ii != null && ii.position == this.mCurItem && child.dispatchPopulateAccessibilityEvent(event)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 13
Source Project: SuperToasts   File: AccessibilityUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Try to send an {@link AccessibilityEvent}
 * for a {@link View}.
 *
 * @param view The View that will dispatch the AccessibilityEvent
 * @return true if the AccessibilityEvent was dispatched
 */
@SuppressWarnings("UnusedReturnValue")
public static boolean sendAccessibilityEvent(View view) {
    final AccessibilityManager accessibilityManager = (AccessibilityManager)
            view.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);

    if (!accessibilityManager.isEnabled()) return false;

    final AccessibilityEvent accessibilityEvent = AccessibilityEvent
            .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
    accessibilityEvent.setClassName(view.getClass().getName());
    accessibilityEvent.setPackageName(view.getContext().getPackageName());

    view.dispatchPopulateAccessibilityEvent(accessibilityEvent);
    accessibilityManager.sendAccessibilityEvent(accessibilityEvent);

    return true;
}
 
Example 14
Source Project: android_9.0.0_r45   File: AdapterView.java    License: Apache License 2.0 5 votes vote down vote up
/** @hide */
@Override
public boolean onRequestSendAccessibilityEventInternal(View child, AccessibilityEvent event) {
    if (super.onRequestSendAccessibilityEventInternal(child, event)) {
        // Add a record for ourselves as well.
        AccessibilityEvent record = AccessibilityEvent.obtain();
        onInitializeAccessibilityEvent(record);
        // Populate with the text of the requesting child.
        child.dispatchPopulateAccessibilityEvent(record);
        event.appendRecord(record);
        return true;
    }
    return false;
}
 
Example 15
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent accessibilityevent)
    {
        int i1 = getChildCount();
        int j1 = 0;
        do
        {
label0:
            {
                boolean flag = false;
                if (j1 < i1)
                {
                    View view = getChildAt(j1);
                    if (view.getVisibility() != 0)
                    {
                        break label0;
                    }
                    F f1 = a(view);
                    if (f1 == null || f1.b != l || !view.dispatchPopulateAccessibilityEvent(accessibilityevent))
                    {
                        break label0;
                    }
                    flag = true;
                }
                return flag;
            }
            j1++;
        } while (true);
    }
 
Example 16
Source Project: Android-SDK-Demo   File: SdkCenteredViewPager.java    License: MIT License 5 votes vote down vote up
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event)
{
    // Dispatch scroll events from this ViewPager.
    if ( event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED )
    {
        return super.dispatchPopulateAccessibilityEvent( event );
    }

    // Dispatch all other accessibility events from the current page.
    final int childCount = getChildCount();
    for ( int i = 0; i < childCount; i++ )
    {
        final View child = getChildAt( i );
        if ( child.getVisibility() == VISIBLE )
        {
            final ItemInfo ii = infoForChild( child );
            if ( ii != null && ii.position == mCurItem &&
                    child.dispatchPopulateAccessibilityEvent( event ) )
            {
                return true;
            }
        }
    }

    return false;
}
 
Example 17
Source Project: android-apps   File: IcsAdapterView.java    License: MIT License 5 votes vote down vote up
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    View selectedView = getSelectedView();
    if (selectedView != null && selectedView.getVisibility() == VISIBLE
            && selectedView.dispatchPopulateAccessibilityEvent(event)) {
        return true;
    }
    return false;
}
 
Example 18
Source Project: letv   File: AdapterView.java    License: Apache License 2.0 5 votes vote down vote up
@TargetApi(14)
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
    if (!super.onRequestSendAccessibilityEvent(child, event)) {
        return false;
    }
    AccessibilityEvent record = AccessibilityEvent.obtain();
    onInitializeAccessibilityEvent(record);
    child.dispatchPopulateAccessibilityEvent(record);
    event.appendRecord(record);
    return true;
}
 
Example 19
Source Project: samples   File: EcoGalleryAdapterView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    boolean populated = false;
    // This is an exceptional case which occurs when a window gets the
    // focus and sends a focus event via its focused child to announce
    // current focus/selection. AdapterView fires selection but not focus
    // events so we change the event type here.
    if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
        event.setEventType(AccessibilityEvent.TYPE_VIEW_SELECTED);
    }

    // we send selection events only from AdapterView to avoid
    // generation of such event for each child
    View selectedView = getSelectedView();
    if (selectedView != null) {
        populated = selectedView.dispatchPopulateAccessibilityEvent(event);
    }

    if (!populated) {
        if (selectedView != null) {
            event.setEnabled(selectedView.isEnabled());
        }
        event.setItemCount(getCount());
        event.setCurrentItemIndex(getSelectedItemPosition());
    }

    return populated;
}
 
Example 20
@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
    if (super.onRequestSendAccessibilityEvent(child, event)) {
        // Add a record for ourselves as well.
        AccessibilityEvent record = AccessibilityEvent.obtain();
        onInitializeAccessibilityEvent(record);
        // Populate with the text of the requesting child.
        child.dispatchPopulateAccessibilityEvent(record);
        event.appendRecord(record);
        return true;
    }
    return false;
}