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 Horizontal-Calendar by Mulham-Raee.
the class HorizontalLayoutManager method smoothScrollToPosition.
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
LinearSmoothScroller smoothScroller = new LinearSmoothScroller(recyclerView.getContext()) {
@Override
public PointF computeScrollVectorForPosition(int targetPosition) {
return HorizontalLayoutManager.this.computeScrollVectorForPosition(targetPosition);
}
// This is the important method. This code will return the amount of time it takes to scroll 1 pixel.
// This code will request Y milliseconds for every <code>smoothScrollSpeed</code> DP units.
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return Y / TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, smoothScrollSpeed, displayMetrics);
}
};
smoothScroller.setTargetPosition(position);
startSmoothScroll(smoothScroller);
}
use of android.support.v7.widget.LinearSmoothScroller in project AwesomeRecyclerView by forceLain.
the class AwesomeLayoutManager method smoothScrollToPosition.
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
if (position >= getItemCount()) {
Log.e(TAG, "Cannot scroll to " + position + ", item count is " + getItemCount());
return;
}
LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()) {
@Override
public PointF computeScrollVectorForPosition(int targetPosition) {
return AwesomeLayoutManager.this.computeScrollVectorForPosition(targetPosition);
}
@Override
protected int getVerticalSnapPreference() {
return SNAP_TO_START;
}
};
scroller.setTargetPosition(position);
startSmoothScroll(scroller);
}
use of android.support.v7.widget.LinearSmoothScroller in project UltimateAndroid by cymcsg.
the class TwoWayLayoutManager method smoothScrollToPosition.
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, State state, int position) {
final LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()) {
@Override
public PointF computeScrollVectorForPosition(int targetPosition) {
if (getChildCount() == 0) {
return null;
}
final int direction = targetPosition < getFirstVisiblePosition() ? -1 : 1;
if (mIsVertical) {
return new PointF(0, direction);
} else {
return new PointF(direction, 0);
}
}
@Override
protected int getVerticalSnapPreference() {
return LinearSmoothScroller.SNAP_TO_START;
}
@Override
protected int getHorizontalSnapPreference() {
return LinearSmoothScroller.SNAP_TO_START;
}
};
scroller.setTargetPosition(position);
startSmoothScroll(scroller);
}
use of android.support.v7.widget.LinearSmoothScroller in project twoway-view by lucasr.
the class TwoWayLayoutManager method smoothScrollToPosition.
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, State state, int position) {
final LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()) {
@Override
public PointF computeScrollVectorForPosition(int targetPosition) {
if (getChildCount() == 0) {
return null;
}
final int direction = targetPosition < getFirstVisiblePosition() ? -1 : 1;
if (mIsVertical) {
return new PointF(0, direction);
} else {
return new PointF(direction, 0);
}
}
@Override
protected int getVerticalSnapPreference() {
return LinearSmoothScroller.SNAP_TO_START;
}
@Override
protected int getHorizontalSnapPreference() {
return LinearSmoothScroller.SNAP_TO_START;
}
};
scroller.setTargetPosition(position);
startSmoothScroll(scroller);
}
Aggregations