Java Code Examples for androidx.recyclerview.widget.OrientationHelper#createHorizontalHelper()

The following examples show how to use androidx.recyclerview.widget.OrientationHelper#createHorizontalHelper() . 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: RecyclerViewPositionHelper.java    From mollyim-android 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 2
Source File: StartSnapHelper.java    From litho with Apache License 2.0 5 votes vote down vote up
@NonNull
private OrientationHelper getHorizontalHelper(@NonNull LayoutManager layoutManager) {
  if (mHorizontalHelper == null || mHorizontalHelperLayoutManager != layoutManager) {
    mHorizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
    mHorizontalHelperLayoutManager = layoutManager;
  }

  return mHorizontalHelper;
}
 
Example 3
Source File: GalleryLayoutManager.java    From CardSlideView with Apache License 2.0 5 votes vote down vote up
private OrientationHelper getOrientationHelper() {
    if (mOrientation == LinearLayout.HORIZONTAL) {
        if (mHorizontalHelper == null) {
            mHorizontalHelper = OrientationHelper.createHorizontalHelper(this);
        }
        return mHorizontalHelper;
    } else {
        if (mVerticalHelper == null) {
            mVerticalHelper = OrientationHelper.createVerticalHelper(this);
        }
        return mVerticalHelper;
    }
}
 
Example 4
Source File: RecyclerViewPositionHelper.java    From aptoide-client-v8 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 5
Source File: RecyclerViewPositionHelper.java    From UltimateRecyclerView with Apache License 2.0 5 votes vote down vote up
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 6
Source File: RecyclerViewPositionHelper.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 7
Source File: CarouselSnapHelper.java    From CarouselView with MIT License 4 votes vote down vote up
private OrientationHelper helper(RecyclerView.LayoutManager layoutManager) {
  if (this.helper == null) {
    this.helper = OrientationHelper.createHorizontalHelper(layoutManager);
  }
  return this.helper;
}
 
Example 8
Source File: GravityDelegate.java    From GetApk with MIT License 4 votes vote down vote up
private OrientationHelper getHorizontalHelper(RecyclerView.LayoutManager layoutManager) {
    if (horizontalHelper == null) {
        horizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
    }
    return horizontalHelper;
}
 
Example 9
Source File: GravitySnapHelper.java    From GravitySnapHelper with Apache License 2.0 4 votes vote down vote up
private OrientationHelper getHorizontalHelper(RecyclerView.LayoutManager layoutManager) {
    if (horizontalHelper == null || horizontalHelper.getLayoutManager() != layoutManager) {
        horizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
    }
    return horizontalHelper;
}
 
Example 10
Source File: SnapToStartHelper.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
private OrientationHelper getHorizontalHelper(RecyclerView.LayoutManager layoutManager) {
  if (horizontalHelper == null) {
    horizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
  }
  return horizontalHelper;
}
 
Example 11
Source File: GravitySnapHelper.java    From MaterialDateTimePicker with Apache License 2.0 4 votes vote down vote up
private OrientationHelper getHorizontalHelper(RecyclerView.LayoutManager layoutManager) {
    if (horizontalHelper == null) {
        horizontalHelper = OrientationHelper.createHorizontalHelper(layoutManager);
    }
    return horizontalHelper;
}