Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6915944f authored by Adam Powell's avatar Adam Powell
Browse files

Expose api on View to determine if the view can be scrolled.

Change-Id: I41783237a975151392faec04c6a85803ebbccfb4
parent 9d9f2372
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21608,6 +21608,8 @@ package android.view {
    method public void buildDrawingCache();
    method public void buildDrawingCache(boolean);
    method public void buildLayer();
    method public boolean canScrollHorizontally(int);
    method public boolean canScrollVertically(int);
    method public void cancelLongPress();
    method public boolean checkInputConnectionProxy(android.view.View);
    method public void clearAnimation();
+34 −0
Original line number Diff line number Diff line
@@ -8450,6 +8450,40 @@ public class View implements Drawable.Callback2, KeyEvent.Callback, Accessibilit
        return getHeight();
    }

    /**
     * Check if this view can be scrolled horizontally in a certain direction.
     *
     * @param direction Negative to check scrolling left, positive to check scrolling right.
     * @return true if this view can be scrolled in the specified direction, false otherwise.
     */
    public boolean canScrollHorizontally(int direction) {
        final int offset = computeHorizontalScrollOffset();
        final int range = computeHorizontalScrollRange() - computeHorizontalScrollExtent();
        if (range == 0) return false;
        if (direction < 0) {
            return offset > 0;
        } else {
            return offset < range - 1;
        }
    }

    /**
     * Check if this view can be scrolled vertically in a certain direction.
     *
     * @param direction Negative to check scrolling up, positive to check scrolling down.
     * @return true if this view can be scrolled in the specified direction, false otherwise.
     */
    public boolean canScrollVertically(int direction) {
        final int offset = computeVerticalScrollOffset();
        final int range = computeVerticalScrollRange() - computeVerticalScrollExtent();
        if (range == 0) return false;
        if (direction < 0) {
            return offset > 0;
        } else {
            return offset < range - 1;
        }
    }

    /**
     * <p>Request the drawing of the horizontal and the vertical scrollbar. The
     * scrollbars are painted only if they have been awakened first.</p>