use of androidx.recyclerview.widget.LinearSmoothScroller in project DiscreteScrollView by yarolegovich.
the class DiscreteScrollLayoutManager method startSmoothPendingScroll.
private void startSmoothPendingScroll() {
LinearSmoothScroller scroller = new DiscreteLinearSmoothScroller(context);
scroller.setTargetPosition(currentPosition);
recyclerViewProxy.startSmoothScroll(scroller);
}
use of androidx.recyclerview.widget.LinearSmoothScroller in project flexbox-layout by google.
the class FlexboxLayoutManager method smoothScrollToPosition.
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
LinearSmoothScroller smoothScroller = new LinearSmoothScroller(recyclerView.getContext());
smoothScroller.setTargetPosition(position);
startSmoothScroll(smoothScroller);
}
use of androidx.recyclerview.widget.LinearSmoothScroller in project Signal-Android by WhisperSystems.
the class SmoothScrollingLinearLayoutManager method smoothScrollToPosition.
public void smoothScrollToPosition(@NonNull Context context, int position, float millisecondsPerInch) {
final LinearSmoothScroller scroller = new LinearSmoothScroller(context) {
@Override
protected int getVerticalSnapPreference() {
return LinearSmoothScroller.SNAP_TO_END;
}
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return millisecondsPerInch / displayMetrics.densityDpi;
}
};
scroller.setTargetPosition(position);
startSmoothScroll(scroller);
}
use of androidx.recyclerview.widget.LinearSmoothScroller in project fdroidclient by f-droid.
the class AppDetailsRecyclerViewAdapter method setShowVersions.
void setShowVersions(boolean showVersions, boolean scrollTo) {
this.showVersions = showVersions;
boolean itemsWereRemoved = items.removeAll(versions);
int startIndex = items.indexOf(VIEWTYPE_VERSIONS) + 1;
// item it will interrupt the nice material-design-style-ripple from the background.
if (showVersions) {
items.addAll(startIndex, versions);
notifyItemRangeInserted(startIndex, versions.size());
if (recyclerView != null && scrollTo) {
final LinearSmoothScroller smoothScroller = new LinearSmoothScroller(context) {
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
// multiple recycler view items
return 75f / displayMetrics.densityDpi;
}
};
// Expanding the version list reveals up to 5 items by default
int visibleVersionLimit = Math.min(versions.size(), 5);
smoothScroller.setTargetPosition(startIndex + visibleVersionLimit - 1);
recyclerView.getLayoutManager().startSmoothScroll(smoothScroller);
}
} else if (itemsWereRemoved) {
notifyItemRangeRemoved(startIndex, versions.size());
if (recyclerView != null && scrollTo) {
recyclerView.smoothScrollToPosition(startIndex - 1);
}
}
}
use of androidx.recyclerview.widget.LinearSmoothScroller in project Signal-Android by signalapp.
the class SmoothScrollingLinearLayoutManager method smoothScrollToPosition.
public void smoothScrollToPosition(@NonNull Context context, int position, float millisecondsPerInch) {
final LinearSmoothScroller scroller = new LinearSmoothScroller(context) {
@Override
protected int getVerticalSnapPreference() {
return LinearSmoothScroller.SNAP_TO_END;
}
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return millisecondsPerInch / displayMetrics.densityDpi;
}
};
scroller.setTargetPosition(position);
startSmoothScroll(scroller);
}
Aggregations