Example usage for android.support.v4.view ViewCompat canScrollHorizontally

List of usage examples for android.support.v4.view ViewCompat canScrollHorizontally

Introduction

In this page you can find the example usage for android.support.v4.view ViewCompat canScrollHorizontally.

Prototype

public static boolean canScrollHorizontally(View v, int direction) 

Source Link

Document

Check if this view can be scrolled horizontally in a certain direction.

Usage

From source file:com.bobomee.android.common.util.ViewUtil.java

public static boolean canScrollLeft(View pView) {
    return ViewCompat.canScrollHorizontally(pView, 1);
}

From source file:com.bobomee.android.common.util.ViewUtil.java

public static boolean canScrollRight(View pView) {
    return ViewCompat.canScrollHorizontally(pView, -1);
}

From source file:com.kerkr.edu.viewUtill.ScrollViewAutoScrollHelper.java

@Override
public boolean canTargetScrollHorizontally(int direction) {
    return ViewCompat.canScrollHorizontally(mTarger, direction);
}

From source file:me.xiaopan.vpc.ViewPagerCompat.java

@Override
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            // TODO: Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }//from  ww  w. j a va 2s. co  m
        }
    }

    if (checkV) {
        // Direct call ViewPager.canScrollHorizontally(int)
        if (v instanceof ViewPager) {
            return ((ViewPager) v).canScrollHorizontally(-dx);
        } else {
            return ViewCompat.canScrollHorizontally(v, -dx);
        }
    } else {
        return false;
    }
}

From source file:com.ouyangzn.view.DragLayout.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    boolean helpResult = mDragHelper.shouldInterceptTouchEvent(ev);
    switch (MotionEventCompat.getActionMasked(ev)) {
    case MotionEvent.ACTION_DOWN:
        mDownX = ev.getX();/*from  ww w . j a v a2s  .  com*/
        mDownY = ev.getY();
        break;
    }
    if (isHorizontalScrollView(mDraggedView)) {
        boolean intercept = false;
        switch (MotionEventCompat.getActionMasked(ev)) {
        case MotionEvent.ACTION_MOVE:
            if (mDirection == DIRECTION_TOP || mDirection == DIRECTION_BOTTOM) {
                // ?--->support-v4DrawerLayout??
                intercept = mDragHelper.checkTouchSlop(ViewDragHelper.DIRECTION_VERTICAL, ev.getPointerId(0));
            } else {
                // ?
                if (ev.getX() - mDownX > 0) {
                    // view????,
                    if (mDirection == DIRECTION_LEFE && mDraggedView.getRight() == mRemainDistance) {
                        intercept = true;
                    } else if (mDirection == DIRECTION_RIGHT) {
                        // view????view??
                        intercept = !ViewCompat.canScrollHorizontally(mDraggedView, -1);
                    }
                }
                // 
                else {
                    // view?????,
                    if (mDirection == DIRECTION_RIGHT
                            && (mLayoutWidth - mDraggedView.getLeft()) == mRemainDistance) {
                        intercept = true;
                    } else if (mDirection == DIRECTION_LEFE) {
                        // view???view??
                        intercept = !ViewCompat.canScrollHorizontally(mDraggedView, 1);
                    }
                }
            }
            // ???view
            if (intercept)
                mDragHelper.captureChildView(mDraggedView, ev.getPointerId(0));
            break;
        }
        return helpResult || intercept;
    }
    if (isVerticalScrollView(mDraggedView)) {
        boolean intercept = false;
        switch (MotionEventCompat.getActionMasked(ev)) {
        case MotionEvent.ACTION_MOVE:
            if (mDirection == DIRECTION_LEFE || mDirection == DIRECTION_RIGHT) {
                // ?--->support-v4DrawerLayout??
                intercept = mDragHelper.checkTouchSlop(ViewDragHelper.DIRECTION_HORIZONTAL, ev.getPointerId(0));
            } else {
                // 
                if (ev.getY() - mDownY > 0) {
                    if (mDirection == DIRECTION_TOP && mDraggedView.getBottom() == mRemainDistance) {
                        intercept = true;
                    } else if (mDirection == DIRECTION_BOTTOM) {
                        intercept = !ViewCompat.canScrollVertically(mDraggedView, -1);
                    }
                }
                // 
                else {
                    // view????
                    if (mDirection == DIRECTION_BOTTOM
                            && (mLayoutHeight - mDraggedView.getBottom()) == mRemainDistance) {
                        intercept = true;
                    } else if (mDirection == DIRECTION_TOP) {
                        // view???view??
                        intercept = !ViewCompat.canScrollVertically(mDraggedView, 1);
                    }
                }
            }
            break;
        }
        Log.d(TAG, "----------onInterceptTouchEvent.return = " + (helpResult || intercept));
        // ???view
        if (intercept)
            mDragHelper.captureChildView(mDraggedView, ev.getPointerId(0));
        return helpResult || intercept;
    }
    return helpResult;
}

From source file:cc.solart.turbo.TurboRecyclerView.java

/**
 * @return Whether it is possible for the child view of this layout to
 * scroll up. Override this if the child view is a custom view.
 */// w  w w  .j  a v  a2 s.c  o  m
private boolean canScrollEnd() {
    return ViewCompat.canScrollVertically(this, 1) || ViewCompat.canScrollHorizontally(this, 1);
}

From source file:cn.liuguangqiang.swipeback.SwipeBackLayout.java

private boolean canChildScrollRight() {
    return ViewCompat.canScrollHorizontally(scrollChild, -1);
}

From source file:cn.liuguangqiang.swipeback.SwipeBackLayout.java

private boolean canChildScrollLeft() {
    return ViewCompat.canScrollHorizontally(scrollChild, 1);
}

From source file:com.ouyangzn.view.DragLayout.java

private boolean isHorizontalScrollView(View view) {
    if (view instanceof RecyclerView) {
        RecyclerView recyclerView = (RecyclerView) view;
        RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
        if (layoutManager instanceof LinearLayoutManager) {
            LinearLayoutManager manager = (LinearLayoutManager) layoutManager;
            if (manager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
                return true;
            }/*from  ww w .jav  a  2s  .c  om*/
        }
    }
    return view instanceof HorizontalScrollView || ViewCompat.canScrollHorizontally(view, -1)
            || ViewCompat.canScrollHorizontally(view, 1);
}

From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.ViewHierarchyElement.java

ViewHierarchyElement(int id, @Nullable ViewHierarchyElement parent, View fromView) {
    // Bookkeeping
    this.id = id;
    this.parentId = (parent != null) ? parent.getId() : null;

    // API 16+ properties
    this.scrollable = AT_16 ? fromView.isScrollContainer() : null;

    // API 11+ properties
    this.backgroundDrawableColor = (AT_11 && (fromView != null)
            && (fromView.getBackground() instanceof ColorDrawable))
                    ? ((ColorDrawable) fromView.getBackground()).getColor()
                    : null;//from w  w  w  .  j a  va  2  s  . c  o  m

    // Base properties
    this.visibleToUser = ViewAccessibilityUtils.isVisibleToUser(fromView);
    this.className = fromView.getClass().getName();
    this.accessibilityClassName = null;
    this.packageName = fromView.getContext().getPackageName();
    this.resourceName = (fromView.getId() != View.NO_ID)
            ? ViewAccessibilityUtils.getResourceNameForView(fromView)
            : null;
    this.contentDescription = SpannableString.valueOf(fromView.getContentDescription());
    this.enabled = fromView.isEnabled();
    if (fromView instanceof TextView) {
        TextView textView = (TextView) fromView;
        // Hint text takes precedence if no text is present.
        CharSequence text = textView.getText();
        if (TextUtils.isEmpty(text)) {
            text = textView.getHint();
        }
        this.text = SpannableString.valueOf(text);
        this.textSize = textView.getTextSize();
        this.textColor = textView.getCurrentTextColor();
        this.typefaceStyle = (textView.getTypeface() != null) ? textView.getTypeface().getStyle() : null;
    } else {
        this.text = null;
        this.textSize = null;
        this.textColor = null;
        this.typefaceStyle = null;
    }

    this.importantForAccessibility = ViewAccessibilityUtils.isImportantForAccessibility(fromView);
    this.clickable = fromView.isClickable();
    this.longClickable = fromView.isLongClickable();
    this.focusable = fromView.isFocusable();
    this.editable = ViewAccessibilityUtils.isViewEditable(fromView);
    this.canScrollForward = (ViewCompat.canScrollVertically(fromView, 1)
            || ViewCompat.canScrollHorizontally(fromView, 1));
    this.canScrollBackward = (ViewCompat.canScrollVertically(fromView, -1)
            || ViewCompat.canScrollHorizontally(fromView, -1));
    this.checkable = (fromView instanceof Checkable);
    this.checked = (fromView instanceof Checkable) ? ((Checkable) fromView).isChecked() : null;
    this.hasTouchDelegate = (fromView.getTouchDelegate() != null);

    // There may be subtle differences between the bounds from a View instance compared to that of
    // its AccessibilityNodeInfo. The latter uses a @hide getBoundsOnScreen method, which clips to
    // parent bounds.
    android.graphics.Rect tempRect = new android.graphics.Rect();
    if (fromView.getGlobalVisibleRect(tempRect)) {
        this.boundsInScreen = new Rect(tempRect);
    } else {
        this.boundsInScreen = null;
    }
    this.nonclippedHeight = fromView.getHeight();
    this.nonclippedWidth = fromView.getWidth();
}