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);
}
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);
}
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);
}
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);
}
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());
}
};
}
Aggregations