Example usage for android.view.accessibility AccessibilityNodeInfo ACTION_SCROLL_FORWARD

List of usage examples for android.view.accessibility AccessibilityNodeInfo ACTION_SCROLL_FORWARD

Introduction

In this page you can find the example usage for android.view.accessibility AccessibilityNodeInfo ACTION_SCROLL_FORWARD.

Prototype

int ACTION_SCROLL_FORWARD

To view the source code for android.view.accessibility AccessibilityNodeInfo ACTION_SCROLL_FORWARD.

Click Source Link

Document

Action to scroll the node content forward.

Usage

From source file:com.appunite.list.AbsHorizontalListView.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override/*from   ww w. ja  va2s  .  co m*/
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (super.performAccessibilityAction(action, arguments)) {
        return true;
    }
    switch (action) {
    case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
        if (isEnabled() && getLastVisiblePosition() < getCount() - 1) {
            final int viewportWidth = getWidth() - mListPadding.left - mListPadding.right;
            smoothScrollBy(viewportWidth, PositionScroller.SCROLL_DURATION);
            return true;
        }
    }
        return false;
    case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
        if (isEnabled() && mFirstPosition > 0) {
            final int viewportWidth = getWidth() - mListPadding.left - mListPadding.right;
            smoothScrollBy(-viewportWidth, PositionScroller.SCROLL_DURATION);
            return true;
        }
    }
        return false;
    }
    return false;
}

From source file:com.liu.hz.view.AbsHorizontalListView.java

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        info.setClassName(AbsHorizontalListView.class.getName());
    }//from w  w w.j av  a  2  s. c  o  m
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (isEnabled()) {
            if (getFirstVisiblePosition() > 0) {
                info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
            }
            if (getLastVisiblePosition() < getCount() - 1) {
                info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
            }
        }
    }
}

From source file:com.appunite.list.AbsListView.java

@Override
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        info.setClassName(AbsListView.class.getName());
    }/*  w w  w.j a v  a  2  s.  c  om*/
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (isEnabled()) {
            if (getFirstVisiblePosition() > 0) {
                info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
            }
            if (getLastVisiblePosition() < getCount() - 1) {
                info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
            }
        }
    }
}

From source file:com.appunite.list.AbsListView.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override/*from  w  w  w.  j  a  v  a  2 s.c  om*/
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (super.performAccessibilityAction(action, arguments)) {
        return true;
    }
    switch (action) {
    case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
        if (isEnabled() && getLastVisiblePosition() < getCount() - 1) {
            final int viewportHeight = getHeight() - mListPadding.top - mListPadding.bottom;
            smoothScrollBy(viewportHeight, PositionScroller.SCROLL_DURATION);
            return true;
        }
    }
        return false;
    case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
        if (isEnabled() && mFirstPosition > 0) {
            final int viewportHeight = getHeight() - mListPadding.top - mListPadding.bottom;
            smoothScrollBy(-viewportHeight, PositionScroller.SCROLL_DURATION);
            return true;
        }
    }
        return false;
    }
    return false;
}

From source file:com.aliasapps.seq.scroller.TwoWayView.java

@Override
@TargetApi(16)/*from w w  w  .jav a  2  s  .c  o  m*/
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (super.performAccessibilityAction(action, arguments)) {
        return true;
    }

    switch (action) {
    case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
        if (isEnabled() && getLastVisiblePosition() < getCount() - 1) {
            final int viewportSize;
            if (mIsVertical) {
                viewportSize = getHeight() - getPaddingTop() - getPaddingBottom();
            } else {
                viewportSize = getWidth() - getPaddingLeft() - getPaddingRight();
            }

            // TODO: Use some form of smooth scroll instead
            scrollListItemsBy(viewportSize);
            return true;
        }
        return false;

    case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
        if (isEnabled() && mFirstPosition > 0) {
            final int viewportSize;
            if (mIsVertical) {
                viewportSize = getHeight() - getPaddingTop() - getPaddingBottom();
            } else {
                viewportSize = getWidth() - getPaddingLeft() - getPaddingRight();
            }

            // TODO: Use some form of smooth scroll instead
            scrollListItemsBy(-viewportSize);
            return true;
        }
        return false;
    }

    return false;
}

From source file:com.artifex.mupdf.view.ThumbnailViews.java

@Override
@TargetApi(16)/*  ww w  . j  a va2 s.c  o m*/
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (super.performAccessibilityAction(action, arguments)) {
        return true;
    }

    switch (action) {
    case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
        if (isEnabled() && getLastVisiblePosition() < getCount() - 1) {
            final int viewportSize;
            if (mIsVertical) {
                viewportSize = getHeight() - getPaddingTop() - getPaddingBottom();
            } else {
                viewportSize = getWidth() - getPaddingLeft() - getPaddingRight();
            }

            // TODO: Use some form of smooth scroll instead
            trackMotionScroll(viewportSize);
            return true;
        }
        return false;

    case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
        if (isEnabled() && mFirstPosition > 0) {
            final int viewportSize;
            if (mIsVertical) {
                viewportSize = getHeight() - getPaddingTop() - getPaddingBottom();
            } else {
                viewportSize = getWidth() - getPaddingLeft() - getPaddingRight();
            }

            // TODO: Use some form of smooth scroll instead
            trackMotionScroll(-viewportSize);
            return true;
        }
        return false;
    }

    return false;
}

From source file:com.artifex.mupdflib.TwoWayView.java

@Override
@TargetApi(16)//from   ww w  .  ja v a  2 s .c om
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (super.performAccessibilityAction(action, arguments)) {
        return true;
    }

    switch (action) {
    case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
        if (isEnabled() && getLastVisiblePosition() < getCount() - 1) {
            // TODO: Use some form of smooth scroll instead
            scrollListItemsBy(getAvailableSize());
            return true;
        }
        return false;

    case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
        if (isEnabled() && mFirstPosition > 0) {
            // TODO: Use some form of smooth scroll instead
            scrollListItemsBy(-getAvailableSize());
            return true;
        }
        return false;
    }

    return false;
}

From source file:com.android.internal.widget.ViewPager.java

@Override
public boolean performAccessibilityAction(int action, Bundle args) {
    if (super.performAccessibilityAction(action, args)) {
        return true;
    }/*from w  ww.  j av  a2 s .  com*/

    switch (action) {
    case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
    case R.id.accessibilityActionScrollRight:
        if (canScrollHorizontally(1)) {
            setCurrentItem(mCurItem + 1);
            return true;
        }
        return false;
    case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
    case R.id.accessibilityActionScrollLeft:
        if (canScrollHorizontally(-1)) {
            setCurrentItem(mCurItem - 1);
            return true;
        }
        return false;
    }

    return false;
}

From source file:cc.flydev.launcher.Page.java

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setScrollable(getPageCount() > 1);
    if (getCurrentPage() < getPageCount() - 1) {
        info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
    }/*from w  w w  .j a va 2 s. co  m*/
    if (getCurrentPage() > 0) {
        info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
    }
}

From source file:cc.flydev.launcher.Page.java

@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (super.performAccessibilityAction(action, arguments)) {
        return true;
    }//  ww w. ja  va  2s  .c  o  m
    switch (action) {
    case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD: {
        if (getCurrentPage() < getPageCount() - 1) {
            scrollRight();
            return true;
        }
    }
        break;
    case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
        if (getCurrentPage() > 0) {
            scrollLeft();
            return true;
        }
    }
        break;
    }
    return false;
}