Package 

Class SnapHelper

    • Method Detail

      • onFling

         boolean onFling(int velocityX, int velocityY)

        Override this to handle a fling given the velocities in both x and y directions.Note that this method will only be called if the associated LayoutManager supports scrolling and the fling is not handled by nested scrolls first.

        Parameters:
        velocityX - the fling velocity on the X axis
        velocityY - the fling velocity on the Y axis
      • attachToRecyclerView

         void attachToRecyclerView(@Nullable() RecyclerView recyclerView)

        Attaches the SnapHelper to the provided RecyclerView, by calling setOnFlingListener.You can call this method with {@code null} to detach it from the current RecyclerView.

        Parameters:
        recyclerView - The RecyclerView instance to which you want to add this helper or{@code null} if you want to remove SnapHelper from the currentRecyclerView.
      • calculateScrollDistance

         Array<int> calculateScrollDistance(int velocityX, int velocityY)

        Calculated the estimated scroll distance in each direction given velocities on both axes.

        Parameters:
        velocityX - Fling velocity on the horizontal axis.
        velocityY - Fling velocity on the vertical axis.
      • findSnapView

        @Nullable() abstract View findSnapView(RecyclerView.LayoutManager layoutManager)

        Override this method to provide a particular target view for snapping.

        This method is called when the SnapHelper is ready to start snapping and requiresa target view to snap to. It will be explicitly called when the scroll state becomes idleafter a scroll. It will also be called when the SnapHelper is preparing to snapafter a fling and requires a reference view from the current set of child views.

        If this method returns {@code null}, SnapHelper will not snap to any view.

        Parameters:
        layoutManager - the RecyclerView.LayoutManager associated with the attachedRecyclerView