Search in sources :

Example 1 with LinearSmoothScroller

use of android.support.v7.widget.LinearSmoothScroller in project ViewPagerIndicator by LuckyJayce.

the class RecyclerIndicatorView method smoothScrollToPosition.

private void smoothScrollToPosition(int position, final int offeset) {
    LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(getContext()) {

        @Override
        public PointF computeScrollVectorForPosition(int targetPosition) {
            PointF pointF = linearLayoutManager.computeScrollVectorForPosition(targetPosition);
            pointF.x += offeset;
            return pointF;
        }
    };
    linearSmoothScroller.setTargetPosition(position);
    linearLayoutManager.startSmoothScroll(linearSmoothScroller);
}
Also used : PointF(android.graphics.PointF) LinearSmoothScroller(android.support.v7.widget.LinearSmoothScroller)

Example 2 with LinearSmoothScroller

use of android.support.v7.widget.LinearSmoothScroller in project android-parallax-recyclerview by kanytu.

the class HeaderLayoutManagerFixed method smoothScrollToPosition.

@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
    LinearSmoothScroller linearSmoothScroller = new LinearSmoothScroller(recyclerView.getContext()) {

        @Override
        public PointF computeScrollVectorForPosition(int targetPosition) {
            return HeaderLayoutManagerFixed.this.computeScrollVectorForPosition(targetPosition);
        }
    };
    linearSmoothScroller.setTargetPosition(position);
    startSmoothScroll(linearSmoothScroller);
}
Also used : LinearSmoothScroller(android.support.v7.widget.LinearSmoothScroller)

Example 3 with LinearSmoothScroller

use of android.support.v7.widget.LinearSmoothScroller in project qksms by moezbhatti.

the class SmoothLinearLayoutManager method smoothScrollToPosition.

@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, final int position) {
    super.smoothScrollToPosition(recyclerView, state, position);
    LinearSmoothScroller smoothScroller = new LinearSmoothScroller(mContext) {

        //This controls the direction in which smoothScroll looks for your view
        @Override
        public PointF computeScrollVectorForPosition(int targetPosition) {
            return new PointF(0, 1);
        }

        //This returns the milliseconds it takes to scroll one pixel.
        @Override
        protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
            return MILLISECONDS_PER_INCH / displayMetrics.densityDpi;
        }
    };
    smoothScroller.setTargetPosition(position);
    startSmoothScroll(smoothScroller);
}
Also used : PointF(android.graphics.PointF) LinearSmoothScroller(android.support.v7.widget.LinearSmoothScroller) DisplayMetrics(android.util.DisplayMetrics)

Example 4 with LinearSmoothScroller

use of android.support.v7.widget.LinearSmoothScroller in project DiscreteScrollView by yarolegovich.

the class DiscreteScrollLayoutManager method startSmoothPendingScroll.

private void startSmoothPendingScroll() {
    LinearSmoothScroller scroller = new DiscreteLinearSmoothScroller(context);
    scroller.setTargetPosition(currentPosition);
    startSmoothScroll(scroller);
}
Also used : LinearSmoothScroller(android.support.v7.widget.LinearSmoothScroller)

Example 5 with LinearSmoothScroller

use of android.support.v7.widget.LinearSmoothScroller in project ChipsLayoutManager by BelooS.

the class HorizontalScrollingController method createSmoothScroller.

@Override
public RecyclerView.SmoothScroller createSmoothScroller(@NonNull Context context, final int position, final int timeMs, final AnchorViewState anchor) {
    return new LinearSmoothScroller(context) {

        /*
             * LinearSmoothScroller, at a minimum, just need to know the vector
             * (x/y distance) to travel in order to get from the current positioning
             * to the target.
             */
        @Override
        public PointF computeScrollVectorForPosition(int targetPosition) {
            int visiblePosition = anchor.getPosition();
            //determine scroll up or scroll down needed
            return new PointF(position > visiblePosition ? 1 : -1, 0);
        }

        @Override
        protected void onTargetFound(View targetView, RecyclerView.State state, Action action) {
            super.onTargetFound(targetView, state, action);
            int currentLeft = layoutManager.getPaddingLeft();
            int desiredLeft = layoutManager.getDecoratedLeft(targetView);
            int dx = desiredLeft - currentLeft;
            //perform fit animation to move target view at top of layoutX
            action.update(dx, 0, timeMs, new LinearInterpolator());
        }
    };
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) AnchorViewState(com.beloo.widget.chipslayoutmanager.anchor.AnchorViewState) PointF(android.graphics.PointF) LinearSmoothScroller(android.support.v7.widget.LinearSmoothScroller) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

LinearSmoothScroller (android.support.v7.widget.LinearSmoothScroller)14 PointF (android.graphics.PointF)9 RecyclerView (android.support.v7.widget.RecyclerView)4 View (android.view.View)4 DisplayMetrics (android.util.DisplayMetrics)3 LinearInterpolator (android.view.animation.LinearInterpolator)2 AnchorViewState (com.beloo.widget.chipslayoutmanager.anchor.AnchorViewState)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1