Java Code Examples for androidx.recyclerview.widget.OrientationHelper#getEndAfterPadding()
The following examples show how to use
androidx.recyclerview.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: GalleryLayoutManager.java From CardSlideView with Apache License 2.0 | 6 votes |
/** * 水平填充布局测量 * * @param recycler RecyclerView.Recycler * @param offset 水平偏移量 */ private void fillWithHorizontal(RecyclerView.Recycler recycler, int offset) { final OrientationHelper orientationHelper = getOrientationHelper(); final int leftEdge = orientationHelper.getStartAfterPadding(); final int rightEdge = orientationHelper.getEndAfterPadding(); if (getChildCount() > 0) { if (offset >= 0) { removeAndRecyclerWithLeft(recycler, leftEdge + offset); } else { removeAndRecyclerWithRight(recycler, rightEdge + offset); } } if (offset >= 0) { // 右滑 fillRight(recycler, rightEdge + offset); } else { // 左滑 fillLeft(recycler, leftEdge + offset); } }
Example 2
Source File: GalleryLayoutManager.java From CardSlideView with Apache License 2.0 | 6 votes |
/** * 垂直填充布局测量 * * @param recycler RecyclerView.Recycler * @param offset 垂直偏移量 */ private void fillWithVertical(RecyclerView.Recycler recycler, int offset) { final OrientationHelper orientationHelper = getOrientationHelper(); final int topEdge = orientationHelper.getStartAfterPadding(); final int bottomEdge = orientationHelper.getEndAfterPadding(); if (getChildCount() > 0) { if (offset >= 0) { // 下滑 removeAndRecyclerWithTop(recycler, topEdge + offset); } else { // 上滑 removeAndRecyclerWithBottom(recycler, bottomEdge + offset); } } if (offset >= 0) { fillBottom(recycler, bottomEdge + offset); } else { fillTop(recycler, topEdge + offset); } }
Example 3
Source File: GravitySnapHelper.java From GravitySnapHelper with Apache License 2.0 | 6 votes |
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 4
Source File: RecyclerViewPositionHelper.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
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 5
Source File: GravityDelegate.java From GetApk with MIT License | 5 votes |
private int distanceToEnd(View targetView, OrientationHelper helper, boolean fromStart) { if (isRtlHorizontal && !fromStart) { return distanceToStart(targetView, helper, true); } return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding(); }
Example 6
Source File: GalleryLayoutManager.java From CardSlideView with Apache License 2.0 | 5 votes |
/** * @param child 计算的view * @param offset view的滑动偏移量 * @return 返回view距离中心轴的距离 */ private int calculateDistanceToCenter(View child, float offset) { final OrientationHelper orientationHelper = getOrientationHelper(); final int centerToStart = (orientationHelper.getEndAfterPadding() - orientationHelper.getStartAfterPadding()) / 2 + orientationHelper.getStartAfterPadding(); if (mOrientation == LinearLayout.HORIZONTAL) { return (int) (child.getWidth() / 2 - offset + child.getLeft() - centerToStart); } else { return (int) (child.getHeight() / 2 - offset + child.getTop() - centerToStart); } }
Example 7
Source File: GalleryLayoutManager.java From CardSlideView with Apache License 2.0 | 5 votes |
@Override public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) { if (mOrientation == LinearLayout.VERTICAL) { return 0; } if (getChildCount() == 0 || dx == 0) { return 0; } int offset = -dx; final OrientationHelper orientationHelper = getOrientationHelper(); final int centerToStart = (orientationHelper.getEndAfterPadding() - orientationHelper.getStartAfterPadding()) / 2 + orientationHelper.getStartAfterPadding(); View child; if (dx > 0) { child = getChildAt(getChildCount() - 1); if (child != null && getPosition(child) == getItemCount() - 1 && !isLooper) { // 计算全部加载完后item的偏移量,右边会留出空隙 offset = -Math.max(0, Math.min(dx, (child.getRight() - child.getLeft()) / 2 + child.getLeft() - centerToStart)); } } else { child = getChildAt(0); if (mFirstVisiblePosition == 0 && child != null && !isLooper) { // 计算首次加载item的偏移量,左边会留出空隙 offset = -Math.min(0, Math.max(dx, ((child.getRight() - child.getLeft()) / 2 + child.getLeft()) - centerToStart)); } } // 记录偏移量 getState().scrollOffset = -offset; fill(recycler, -offset); offsetChildrenHorizontal(offset); return -offset; }
Example 8
Source File: RecyclerViewPositionHelper.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
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 9
Source File: RecyclerViewPositionHelper.java From UltimateRecyclerView with Apache License 2.0 | 5 votes |
private 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 10
Source File: RecyclerViewPositionHelper.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
View findOneVisibleChild(int fromIndex, int toIndex, boolean completelyVisible, boolean acceptPartiallyVisible) { OrientationHelper helper; if (linearLayoutManager.canScrollVertically()) { helper = OrientationHelper.createVerticalHelper(linearLayoutManager); } else { helper = OrientationHelper.createHorizontalHelper(linearLayoutManager); } 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 = linearLayoutManager.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 11
Source File: GravitySnapHelper.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
private int distanceToEnd(View targetView, OrientationHelper helper, boolean fromStart) { if (isRtlHorizontal && !fromStart) { return distanceToStart(targetView, helper, true); } return helper.getDecoratedEnd(targetView) - helper.getEndAfterPadding(); }