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

The following examples show how to use android.view.View#dispatchPopulateAccessibilityEvent() . 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
Source File: ViewPagerCompat.java    From android-auto-scroll-viewpager with 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 2
Source File: AccessibilityUtils.java    From SuperToasts with 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 3
Source File: ViewPager.java    From letv with 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 4
Source File: VelocityViewPager.java    From Muzesto with GNU General Public License v3.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 5
Source File: ViewPagerEx.java    From ImageSliderWithSwipes with 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 6
Source File: YViewPagerNew.java    From YViewPagerDemo with 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 7
Source File: ViewPager.java    From android-recipes-app with 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 File: VerticalViewPager.java    From ticdesign with 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 File: FuckViewPager.java    From nono-android with GNU General Public License v3.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 10
Source File: SliderPager.java    From Android-Image-Slider with Apache License 2.0 6 votes vote down vote up
@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 11
Source File: CoolViewPager.java    From CoolViewPager with 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 12
Source File: VerticalViewPager.java    From Overchan-Android with GNU General Public License v3.0 6 votes vote down vote up
@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 13
Source File: RelativeLayout.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** @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 14
Source File: SdkCenteredViewPager.java    From Android-SDK-Demo with 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 15
Source File: IcsAdapterView.java    From android-apps with 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 16
Source File: VerticalViewPager.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
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 17
Source File: AdapterView.java    From letv with 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 18
Source File: AdapterView.java    From android_9.0.0_r45 with 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 19
Source File: EcoGalleryAdapterView.java    From samples with 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
Source File: IcsAdapterView.java    From Libraries-for-Android-Developers with MIT License 5 votes vote down vote up
@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;
}