Example usage for android.view.accessibility AccessibilityNodeInfo ACTION_SCROLL_BACKWARD

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

Introduction

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

Prototype

int ACTION_SCROLL_BACKWARD

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

Click Source Link

Document

Action to scroll the node content backward.

Usage

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

@Override
@TargetApi(16)/*from  w  w  w .  j  av  a 2s  . com*/
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  .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) {
            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 w  w  w .  j a va2s .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;
    }//  w w w . ja  v  a2 s.  c  om

    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  www  .  j a  va 2 s  .  c  om
    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;
    }//from   w w w  .j av  a2  s .co 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;
}