Search in sources :

Example 1 with LinearSmoothScroller

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);
}
Also used : LinearSmoothScroller(androidx.recyclerview.widget.LinearSmoothScroller)

Example 2 with LinearSmoothScroller

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);
}
Also used : LinearSmoothScroller(androidx.recyclerview.widget.LinearSmoothScroller)

Example 3 with LinearSmoothScroller

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);
}
Also used : LinearSmoothScroller(androidx.recyclerview.widget.LinearSmoothScroller) DisplayMetrics(android.util.DisplayMetrics)

Example 4 with LinearSmoothScroller

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);
        }
    }
}
Also used : LinearSmoothScroller(androidx.recyclerview.widget.LinearSmoothScroller) DisplayMetrics(android.util.DisplayMetrics) SuppressLint(android.annotation.SuppressLint)

Example 5 with LinearSmoothScroller

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);
}
Also used : LinearSmoothScroller(androidx.recyclerview.widget.LinearSmoothScroller) DisplayMetrics(android.util.DisplayMetrics)

Aggregations

LinearSmoothScroller (androidx.recyclerview.widget.LinearSmoothScroller)7 DisplayMetrics (android.util.DisplayMetrics)3 SuppressLint (android.annotation.SuppressLint)1 SharedPreferences (android.content.SharedPreferences)1 CheckBoxPreference (androidx.preference.CheckBoxPreference)1 EditTextPreference (androidx.preference.EditTextPreference)1 ListPreference (androidx.preference.ListPreference)1 Preference (androidx.preference.Preference)1 PreferenceCategory (androidx.preference.PreferenceCategory)1 SeekBarPreference (androidx.preference.SeekBarPreference)1 Languages (org.fdroid.fdroid.Languages)1 Preferences (org.fdroid.fdroid.Preferences)1