Java Code Examples for android.support.v7.widget.OrientationHelper#getEndAfterPadding()

The following examples show how to use android.support.v7.widget.OrientationHelper#getEndAfterPadding() . 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: GravitySnapHelper.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
private int getDistanceToEnd(View targetView, @NonNull OrientationHelper helper) {
    int distance;

    if (!snapToPadding) {
        int childEnd = helper.getDecoratedEnd(targetView);
        if (childEnd >= helper.getEnd() - (helper.getEnd() - helper.getEndAfterPadding()) / 2) {
            distance = helper.getDecoratedEnd(targetView) - helper.getEnd();
        } else {
            distance = childEnd - helper.getEndAfterPadding();
        }
    } else {
        distance = helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
    }

    return distance;
}
 
Example 2
Source File: ScrollPageHelper.java    From YCScrollPager with Apache License 2.0 5 votes vote down vote up
private int distanceToEnd(View targetView, @NonNull OrientationHelper helper, boolean fromStart) {
    if (isRtlHorizontal && !fromStart) {
        return distanceToStart(targetView, helper, true);
    }

    return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
Example 3
Source File: RecyclerViewPositionHelper.java    From Ticket-Analysis with MIT License 5 votes vote down vote up
View findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible,
                         boolean acceptPartiallyVisible) {
    OrientationHelper helper;
    if (layoutManager.canScrollVertically()) {
        helper = OrientationHelper.createVerticalHelper(layoutManager);
    } else {
        helper = OrientationHelper.createHorizontalHelper(layoutManager);
    }

    final int start = helper.getStartAfterPadding();
    final int end = helper.getEndAfterPadding();
    final int next = toIndex > fromIndex ? 1 : -1;
    View partiallyVisible = null;
    for (int i = fromIndex; i != toIndex; i += next) {
        final View child = layoutManager.getChildAt(i);
        final int childStart = helper.getDecoratedStart(child);
        final int childEnd = helper.getDecoratedEnd(child);
        if (childStart < end && childEnd > start) {
            if (completelyVisible) {
                if (childStart >= start && childEnd <= end) {
                    return child;
                } else if (acceptPartiallyVisible && partiallyVisible == null) {
                    partiallyVisible = child;
                }
            } else {
                return child;
            }
        }
    }
    return partiallyVisible;
}
 
Example 4
Source File: GravityDelegate.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
private int distanceToEnd(View targetView, OrientationHelper helper, boolean fromStart) {
    if (isRtlHorizontal && !fromStart) {
        return distanceToStart(targetView, helper, true);
    }

    return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
Example 5
Source File: GalleryLayoutManager.java    From YCBanner with Apache License 2.0 5 votes vote down vote up
/**
 * @param child
 * @param pendingOffset child view will scroll by
 * @return
 */
private int calculateDistanceCenter(View child, float pendingOffset) {
    OrientationHelper orientationHelper = getOrientationHelper();
    int parentCenter = (orientationHelper.getEndAfterPadding() - orientationHelper.getStartAfterPadding()) / 2 + orientationHelper.getStartAfterPadding();
    if (mOrientation == GalleryLayoutManager.HORIZONTAL) {
        return (int) (child.getWidth() / 2 - pendingOffset + child.getLeft() - parentCenter);
    } else {
        return (int) (child.getHeight() / 2 - pendingOffset + child.getTop() - parentCenter);
    }

}
 
Example 6
Source File: ScrollPageHelper.java    From YCBanner with Apache License 2.0 5 votes vote down vote up
private int distanceToEnd(View targetView, @NonNull OrientationHelper helper, boolean fromStart) {
    if (isRtlHorizontal && !fromStart) {
        return distanceToStart(targetView, helper, true);
    }

    return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
Example 7
Source File: GravitySnapHelper.java    From MangoBloggerAndroidApp with Mozilla Public License 2.0 5 votes vote down vote up
private int distanceToEnd(View targetView, OrientationHelper helper, boolean fromStart) {
    if (mIsRtlHorizontal && !fromStart) {
        return distanceToStart(targetView, helper, true);
    }

    return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
Example 8
Source File: ScrollPageHelper.java    From YCRefreshView with Apache License 2.0 5 votes vote down vote up
private int distanceToEnd(View targetView, @NonNull OrientationHelper helper, boolean fromStart) {
    if (isRtlHorizontal && !fromStart) {
        return distanceToStart(targetView, helper, true);
    }

    return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
Example 9
Source File: GalleryLayoutManager.java    From GalleryLayoutManager with Apache License 2.0 5 votes vote down vote up
/**
 * @param child
 * @param pendingOffset child view will scroll by
 * @return
 */
private int calculateDistanceCenter(View child, float pendingOffset) {
    OrientationHelper orientationHelper = getOrientationHelper();
    int parentCenter = (orientationHelper.getEndAfterPadding() - orientationHelper.getStartAfterPadding()) / 2 + orientationHelper.getStartAfterPadding();
    if (mOrientation == GalleryLayoutManager.HORIZONTAL) {
        return (int) (child.getWidth() / 2 - pendingOffset + child.getLeft() - parentCenter);
    } else {
        return (int) (child.getHeight() / 2 - pendingOffset + child.getTop() - parentCenter);
    }

}
 
Example 10
Source File: GravitySnapHelper.java    From date_picker_converter with Apache License 2.0 5 votes vote down vote up
private int distanceToEnd(View targetView, OrientationHelper helper, boolean fromStart) {
    if (isRtlHorizontal && !fromStart) {
        return distanceToStart(targetView, helper, true);
    }

    return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding();
}
 
Example 11
Source File: RecyclerViewPositionHelper.java    From PullLoadView with Apache License 2.0 5 votes vote down vote up
public View findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible,
                         boolean acceptPartiallyVisible) {
    OrientationHelper helper;
    if (layoutManager.canScrollVertically()) {
        helper = OrientationHelper.createVerticalHelper(layoutManager);
    } else {
        helper = OrientationHelper.createHorizontalHelper(layoutManager);
    }

    final int start = helper.getStartAfterPadding();
    final int end = helper.getEndAfterPadding();
    final int next = toIndex > fromIndex ? 1 : -1;
    View partiallyVisible = null;
    for (int i = fromIndex; i != toIndex; i += next) {
        final View child = layoutManager.getChildAt(i);
        final int childStart = helper.getDecoratedStart(child);
        final int childEnd = helper.getDecoratedEnd(child);
        if (childStart < end && childEnd > start) {
            if (completelyVisible) {
                if (childStart >= start && childEnd <= end) {
                    return child;
                } else if (acceptPartiallyVisible && partiallyVisible == null) {
                    partiallyVisible = child;
                }
            } else {
                return child;
            }
        }
    }
    return partiallyVisible;
}
 
Example 12
Source File: RecyclerViewPositionHelper.java    From KAM with GNU General Public License v3.0 5 votes vote down vote up
View findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible, boolean acceptPartiallyVisible) {
    OrientationHelper helper;
    if (layoutManager.canScrollVertically()) {
        helper = OrientationHelper.createVerticalHelper(layoutManager);
    } else {
        helper = OrientationHelper.createHorizontalHelper(layoutManager);
    }

    final int start = helper.getStartAfterPadding();
    final int end = helper.getEndAfterPadding();
    final int next = toIndex > fromIndex ? 1 : -1;
    View partiallyVisible = null;
    for (int i = fromIndex; i != toIndex; i += next) {
        final View child = layoutManager.getChildAt(i);
        final int childStart = helper.getDecoratedStart(child);
        final int childEnd = helper.getDecoratedEnd(child);
        if (childStart < end && childEnd > start) {
            if (completelyVisible) {
                if (childStart >= start && childEnd <= end) {
                    return child;
                } else if (acceptPartiallyVisible && partiallyVisible == null) {
                    partiallyVisible = child;
                }
            } else {
                return child;
            }
        }
    }
    return partiallyVisible;
}
 
Example 13
Source File: RecyclerViewPositionHelper.java    From mugen with Apache License 2.0 5 votes vote down vote up
View findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible,
                         boolean acceptPartiallyVisible) {
    OrientationHelper helper;
    if (layoutManager.canScrollVertically()) {
        helper = OrientationHelper.createVerticalHelper(layoutManager);
    } else {
        helper = OrientationHelper.createHorizontalHelper(layoutManager);
    }

    final int start = helper.getStartAfterPadding();
    final int end = helper.getEndAfterPadding();
    final int next = toIndex > fromIndex ? 1 : -1;
    View partiallyVisible = null;
    for (int i = fromIndex; i != toIndex; i += next) {
        final View child = layoutManager.getChildAt(i);
        final int childStart = helper.getDecoratedStart(child);
        final int childEnd = helper.getDecoratedEnd(child);
        if (childStart < end && childEnd > start) {
            if (completelyVisible) {
                if (childStart >= start && childEnd <= end) {
                    return child;
                } else if (acceptPartiallyVisible && partiallyVisible == null) {
                    partiallyVisible = child;
                }
            } else {
                return child;
            }
        }
    }
    return partiallyVisible;
}