Giter Site home page Giter Site logo

recyclerview-fastscroll's Introduction

RecyclerView-FastScroll

Maven Central API License Build Status

A simple FastScroller for Android's RecyclerView.

Supports vertical RecyclerViews using either LinearLayoutManager or GridLayoutManager (including multiple spans).

The style is loosely based on the ListView FastScroller from whatever the last version of Lollipop was. This library borrows heavily from Google's Launcher3 FastScroller

Screenshot

Gradle

compile 'com.simplecityapps:recyclerview-fastscroll:2.0.1'

Usage

You must use FastScrollRecyclerView as your base RecyclerView. See the sample project if you're having trouble.

Via xml:

<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
    android:id="@+id/recycler"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:fastScrollPopupBgColor="@color/colorAccent"
    app:fastScrollPopupTextColor="@android:color/primary_text_dark"
    app:fastScrollThumbColor="@color/colorAccent" />

To display the FastScrollPopup, your adapter must implement FastScrollRecyclerView.SectionedAdapter and override getSectionName().

If you need to know when fast-scrolling starts or stops, you can attach an OnFastScrollStateChangedListener to the FastScrollRecyclerView.

Varying Row Heights

By default, FastScrollRecyclerView assumes that all items in the adapter have the same height. If your adapter has item views with different heights, then you should make your adapter implement the MeasurableAdapter interface and override getViewTypeHeight() – otherwise the scroll thumb may not appear in the correct position and scrolling may be inconsistent.

getViewTypeHeight() returns the height of a single view of a given type in pixels. The height of each view must be fixed and constant between all instances of a view type. Because the implementor is responsible for computing this value before views are laid out, this is not suitable for view types where the height of a view is determined by a variable number of lines of text that the item consumes.

Currently, MeasurableAdapter only works with LinearLayoutManager. Using MeasurableAdapter with a GridLayoutManager that has more than one span will cause the scrollbar thumb to reach the bottom of the list before the halfway point on the scrollbar's background.

Customisation

You can enable/disable autohide using the fastScrollAutoHide & fastScrollAutoHideDelay attributes in xml:

 <com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
     app:fastScrollAutoHide="true"
     app:fastScrollAutoHideDelay="1500"
     ...

Or programmatically via setAutoHideDelay(int hideDelay) and setAutoHideEnabled(boolean autoHideEnabled)

The following can be styled via xml:

  • Popup background
  • Popup text
  • Popup background size
  • Popup text size
  • Track width and background
  • Thumb width and color
  • Popup position
  • Popup text vertical alignment mode
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
    app:fastScrollPopupBgColor="@color/colorAccent"
    app:fastScrollPopupTextColor="@android:color/primary_text_dark"
    app:fastScrollPopupTextSize="56sp"
    app:fastScrollPopupBackgroundSize="88dp"
    app:fastScrollThumbColor="@color/colorAccent"
    app:fastScrollThumbWidth="6dp"
    app:fastScrollTrackColor="#1f000000"
    app:fastScrollTrackWidth="8dp"
    app:fastScrollPopupPosition="adjacent"
    app:fastScrollPopupTextVerticalAlignmentMode="fontMetrics"/>
    ...

Or programmatically via

  • setThumbColor(@ColorInt int color)
  • setTrackColor(@ColorInt int color)
  • setPopupBgColor(@ColorInt int color)
  • setPopupTextColor(@ColorInt int color)
  • setPopupTextSize(int size)
  • setPopupPosition(@FastScroller.FastScrollerPopupPosition int position)

You can enable/disable fast-scrolling via:

<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
    app:fastScrollThumbEnabled="false"
    ...

Or programmatically via setFastScrollThumbEnabled(boolean enabled)

recyclerview-fastscroll's People

Contributors

andrewbailey avatar bcsl avatar ebomike avatar g00fy2 avatar geometer avatar huikaihoo avatar jahirfiquitiva avatar kabouzeid avatar mathieupost avatar nadavfima avatar nammari avatar timusus avatar vfishv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

recyclerview-fastscroll's Issues

Crash on API <= 15

I capture multiple crashes on API lower then 15 from Crashlytics. A user reported that he cannot enter the Activity Screen totally.

Fatal Exception: java.lang.NullPointerException
at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:513)
at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:385)
at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:537)
at android.animation.ValueAnimator.start(ValueAnimator.java:927)
at android.animation.ValueAnimator.start(ValueAnimator.java:950)
at android.animation.ObjectAnimator.start(ObjectAnimator.java:363)
at com.simplecityapps.recyclerview_fastscroll.views.FastScroller$1.run(FastScroller.java:124)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4512)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:982)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
at dalvik.system.NativeStart.main(NativeStart.java)

Autohide not working or even crashing

Hi,

There are some cases where the autohide feature is not working for me. In Android 4.x it's even crashing:

Fatal Exception: java.lang.NullPointerException
       at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:513)
       at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:392)
       at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:544)
       at android.animation.ValueAnimator.start(ValueAnimator.java:934)
       at android.animation.ValueAnimator.start(ValueAnimator.java:957)
       at android.animation.ObjectAnimator.start(ObjectAnimator.java:370)
       at com.simplecityapps.recyclerview_fastscroll.views.FastScroller$1.run(SourceFile:118)
       at android.os.Handler.handleCallback(Handler.java:605)

This is my XML:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:fastScrollAutoHide="true"
        app:fastScrollAutoHideDelay="1500"
        app:fastScrollPopupBgColor="@color/accent"
        app:fastScrollPopupTextColor="@android:color/white"
        app:fastScrollThumbColor="@color/accent"
        />

    <ProgressBar
        android:id="@+id/list_progressbar"
        android:layout_gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        />

    <TextView
        android:id="@+id/contact_list_all_empty_text"
        android:layout_gravity="center"
        android:textAppearance="@style/TextAppearance.AppCompat.Body1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/empty_title"
        android:visibility="gone"
        />

</FrameLayout>

Any clue what might be happening?

Thanks!

java.lang.ArithmeticException: divide by zero

java.lang.ArithmeticException: divide by zero
               at com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView.scrollToPositionAtProgress(FastScrollRecyclerView.java:297)
               at com.simplecityapps.recyclerview_fastscroll.views.FastScroller.handleTouchEvent(FastScroller.java:205)
               at com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView.handleTouchEvent(FastScrollRecyclerView.java:138)
               at com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView.onTouchEvent(FastScrollRecyclerView.java:118)
               at android.support.v7.widget.RecyclerView.dispatchOnItemTouch(RecyclerView.java:2756)
               at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2899)
 override fun getSectionName(position: Int): String =
            sections[getSectionForAdapterPosition(position)].name

This error happen when scrolling.
Is there a any solution?

FastScrollPopup - Not working for some reason when compiled from gradle?

The only thing I am changing is using a local build of the library, maybe an older version then switching to using the gradle link:

compile 'com.simplecityapps:recyclerview-fastscroll:1.0.5'

And then the SectionIndexer method 'getSectionForPosition' doesn't seem to get called. Any thoughts?

RTL support for the thumb.

The picture should explain everything in this case, just wanted to track this here so it doesn't become forgotten.

2016 - 1

Change width of scroll thumb

The width of the scroll thumb should be changeable. The FastScroll thumb is about twice the width of the original one.

Add support for ItemDecorations

Currently not supported. Any RecyclerView with item decorations will have weird FastScroll positions, due to the height of the decorations not being taken into account.

Scroll Popup not disappearing

On certain devices (Nexus 6P, Nexus 5X, Moto G3, etc.) the section popup doesn't disappear after the user has stopped scrolling.

Issue with items with different height

Hello
I have 3 types of view in my RecyclerView with different heights.
In my case RecyclerView-FastScroll dose not work correctly.
Is it possible to fix it?

Thanks

Fastscroller doesn't respect padding.

This is important to make it work with a collapsing toolbar for example. In this case the bottom padding changes when the toolbar collapses/expands. Because of that, currently a part of the fastscroller moves out of the screen when the toolbar is expanded.

Not really related to the CollapsingToolbarLayout, but a definite issue none the less. The FastScroll should respect the padding of its parent.

child is null

happens when you return to the fragment having the recyclerview, there is a view element (like top shadow) overlapping on the recyclerview and it hasn't scrolled yet, i assume it tries to find the shadow within the recyclerview and fails

03-08 15:43:21.575  11532-11532/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.thecircle.debug, PID: 11532
    java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getTop()' on a null object reference
            at android.support.v7.widget.RecyclerView$LayoutManager.getDecoratedTop(RecyclerView.java:7654)
            at com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView.getCurScrollState(FastScrollRecyclerView.java:315)
            at com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView.onUpdateScrollbar(FastScrollRecyclerView.java:286)
            at com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView.draw(FastScrollRecyclerView.java:169)
            at android.view.View.updateDisplayListIfDirty(View.java:15180)
            at android.view.View.draw(View.java:15954)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
            at android.view.View.updateDisplayListIfDirty(View.java:15175)
            at android.view.View.draw(View.java:15954)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
            at android.view.View.draw(View.java:16187)
            at android.view.View.updateDisplayListIfDirty(View.java:15180)
            at android.view.View.draw(View.java:15954)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
            at android.view.View.updateDisplayListIfDirty(View.java:15175)
            at android.view.View.draw(View.java:15954)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
            at android.view.View.updateDisplayListIfDirty(View.java:15175)
            at android.view.View.draw(View.java:15954)
            at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
            at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1369)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
            at android.view.View.updateDisplayListIfDirty(View.java:15175)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
            at android.view.View.updateDisplayListIfDirty(View.java:15140)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
            at android.view.View.updateDisplayListIfDirty(View.java:15140)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
            at android.view.View.updateDisplayListIfDirty(View.java:15140)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
            at android.view.View.updateDisplayListIfDirty(View.java:15140)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
            at android.view.View.updateDisplayListIfDirty(View.java:15140)
            at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
            at android.view.View.updateDisplayListIfDirty(View.java:15140)
            at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
            at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
            at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)
            at android.view.ViewRootImpl.draw(ViewRootImpl.java:2615)
            at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2434)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2067)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
            at android.view.Choreographer.doCallbacks(Choreographer.java:670)
            at android.view.Choreographer.doFrame(Choreographer.java:606)
            at android.view.Choreographer$FrameDisplayEventReceiver.ru

Different Viewtypes

I am using 2 different viewtypes (a textview and a cardview) for the recyclerview. When the type is changing in the recyclerview while scrolling it is lagging (scroll bar is jumping up and down like crazy).
In getSectionedName I'm is always returning "A"
Any fixes?

Add interface for fast scroll state change

It would be very useful to have an interface to determine when fast scrolling has begun and ended (and possibly any states/offsets in between).

In my case, I have a layout that includes a FastScrollRecyclerView and a FloatingActionButton in a FrameLayout. I want to be able to hide the FAB when a user is fast scrolling - as the fast scroll popup goes under the FAB - and show it again when the user stops.

This may also help to solve the issue of the RecyclerView.onScrollListener not being called for scrollToPosition (see: http://stackoverflow.com/questions/27819507/recyclerview-scrolltoposition-not-trigger-scrolllistener).

Popup background color alpha ignored

If I set a popup background color with alpha, like e.g. #997F7F7F, only RGB spectrum is used. Please check also another color attributes and fix

Scroll thumbnail is not hiding in release builds with obfuscation

I am currently adding the following proguard config to fix it:

# ---- FastScrollRecycleView ----
-keep class com.simplecityapps.recyclerview_fastscroll.** { *; }
# ---- END FastScrollRecycleView ----

Please add a note or include progurd rules into your lib.

GridLayoutManager can't get correct height

if i use GridLayoutManager,how can i get correct height?

        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                switch (mReAdapter.getItemViewType(position)) {
                    case R.layout.album_item_header:
                        return 3;
                    default:
                        return 1;
                }
            }
        });
        rv_fastScroll.setLayoutManager(gridLayoutManager);
        rv_fastScroll.setAdapter(mReAdapter);


          @Override
                public int getViewTypeHeight(RecyclerView recyclerView, int viewType) {


                    //recyclerView.getResources().getDimensionPixelSize(R.dimen.list_item_height)
                    return viewType == R.layout.album_item_header ? DeviceConstant.HEIGHT * ImageSpecial.Spec.PX_90 / ImageSpecial.Spec.PX_HEIGHT : viewType == R.layout.album_item ? DeviceConstant.HEIGHT * ImageSpecial.Spec.PX_248 / 3 / ImageSpecial.Spec.PX_HEIGHT : 0;
                }

Render problem

Hi,

I just added library to project however I'm getting rendering problem. Any idea what can cause this?

java.lang.IllegalArgumentException: java.lang.ClassCastException@73980bc4
	at sun.reflect.GeneratedMethodAccessor1056.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108)
	at android.animation.PropertyValuesHolder_Delegate.nCallIntMethod(PropertyValuesHolder_Delegate.java:140)
	at android.animation.PropertyValuesHolder.nCallIntMethod(PropertyValuesHolder.java)
	at android.animation.PropertyValuesHolder.access$200(PropertyValuesHolder.java:38)
	at android.animation.PropertyValuesHolder$IntPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1221)
	at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:989)
	at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:612)
	at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:578)
	at android.animation.ValueAnimator.start(ValueAnimator.java:1001)
	at android.animation.ValueAnimator.start(ValueAnimator.java:1010)
	at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
	at com.simplecityapps.recyclerview_fastscroll.views.FastScroller.show(FastScroller.java:306)
	at com.simplecityapps.recyclerview_fastscroll.views.FastScroller$2.onScrolled(FastScroller.java:148)
	at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:4618)
	at android.support.v7.widget.RecyclerView.dispatchLayoutStep3(RecyclerView.java:3679)
	at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3323)
	at android.support.v7.widget.RecyclerView.onLayout_Original(RecyclerView.java:3844)
	at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java)
	at android.view.View.layout(View.java:17523)
	at android.view.ViewGroup.layout(ViewGroup.java:5612)
	at android.support.constraint.ConstraintLayout.onLayout_Original(ConstraintLayout.java:1197)
	at android.support.constraint.ConstraintLayout.onLayout(ConstraintLayout.java)
	at android.view.View.layout(View.java:17523)
	at android.view.ViewGroup.layout(ViewGroup.java:5612)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:17523)
	at android.view.ViewGroup.layout(ViewGroup.java:5612)
	at android.support.v7.widget.ActionBarOverlayLayout.onLayout_Original(ActionBarOverlayLayout.java:437)
	at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java)
	at android.view.View.layout(View.java:17523)
	at android.view.ViewGroup.layout(ViewGroup.java:5612)
	at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
	at android.view.View.layout(View.java:17523)
	at android.view.ViewGroup.layout(ViewGroup.java:5612)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:345)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
	at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
	at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:567)
	at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:549)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863)
	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:549)
	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$1(RenderTask.java:680)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

ScrollToPosition

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.scrollToPosition(int)' on a null object reference

Not able to change tex size of text in popup

It says in readme that it should be possible to change the text size of the text in the popup using setPopupTextSize(int size), but I don't find any methods supporting this in code. The others for setting background- and text color is there, but not size.

Separate padding left|top|right|bottom

I need of distinguishing between padding left and other paddings of fastscroll.
Now all paddings have the same value : fastscroll_scrollbar_padding.

Can you separate them with for example
fastscroll_scrollbar_padding_left
fastscroll_scrollbar_padding_top
ecc...?

Thanks

Methods to show or hide scroller

Hey @timusus

There are situations when we need to dynamically show or hide the scroller so because there could be method to hide the scroller and show it when required.

Popup not showing

I have a simple RecyclerView extending FastScrollRecyclerView whose adapter is a RecyclerView.Adapter implementing FastScrollRecyclerView.SectionedAdapter. The FastScroll thumb shows and works just fine, but the popup does not show when scrolling.

This is my RecyclerView XML:

<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
        android:id="@+id/track_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:fastScrollPopupBgColor="@color/colorAccent"
        app:fastScrollPopupTextColor="@android:color/primary_text_dark"
        app:fastScrollThumbColor="@color/colorAccent"
        app:fastScrollPopupBackgroundSize="88dp"
        app:fastScrollPopupTextSize="56sp"/>

And this is my getSectionName() method:

@NonNull
@Override
public String getSectionName(int position)
{
    if (position > 0) position--; // the 0th position is not a track

    return Character.toString(tracks.get(position).getTitle().charAt(0));
}

I am using an itemDecoration that separates the items by 2dp.

FastScroll triggers SwipeRefreshLayout

When you scroll down, the SwipeRefresh call is triggered. But the scroll goes up perfectly. A temporary solution is to set the SweepRefresh setEnabled(false) on start scrolling and setEnabled(true) on stop

NullPointerException if adapter not set

If the adapter of the recycler view is not (yet) set, the recycler view crashes with a NullPointerException on the first frame to draw (calling getItemCount() on the null adapter).

This is counter intuitive and annoying especially when working with loaders or even cursor loaders. You have to write the adapter null safe and instantiate and set an empty adapter with a null cursor every time the loader is reset. This is an ugly workaround.

Popup size changing for fex pixels when new selection name

See the logcat below. While scrolling in the sample app within the range of 10 -99 the popup size (bgWidth) jumps between 328 - 332 px. This causes the popup to slightly flicker and lock restless.

08-21 23:05:02.738 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 330 (71)
08-21 23:05:02.754 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 330 (71)
08-21 23:05:02.771 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 330 (71)
08-21 23:05:02.787 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 330 (71)
08-21 23:05:02.803 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 330 (71)
08-21 23:05:02.821 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 328 (70)
08-21 23:05:02.837 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 328 (70)
08-21 23:05:02.852 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 328 (70)
08-21 23:05:02.869 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 332 (72)
08-21 23:05:02.885 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 332 (72)
08-21 23:05:02.902 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 330 (71)
08-21 23:05:02.918 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 330 (71)
08-21 23:05:02.934 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 330 (71)
08-21 23:05:02.951 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 330 (71)
08-21 23:05:02.967 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 332 (72)
08-21 23:05:02.985 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 332 (72)
08-21 23:05:03.000 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 332 (72)
08-21 23:05:03.018 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 332 (72)
08-21 23:05:03.034 11956-11956/com.simplecityapps.recyclerview_fastscroll.sample D/bgWidth (bgPadding): 328 (70)

I have some ideas how to address this. The easiest way would be to add some rounding, but is not 100% reliable. Other ways I try is to get the max width of the used typeface or to force monospace text drawing. Will add a PR as soon as I found a solid solution.

Gridlayout giving too much bottom margin below every item in recyclerview

Here's my java code:
recyclerView = ((FastScrollRecyclerView)v.findViewById(R.id.recyclerView)); recyclerView.setAdapter(new BaseAdapter()); recyclerView.hasFixedSize(); recyclerView.setLayoutManager(new GridLayoutManager(getActivity().getApplicationContext(),2));

XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activities.Main2Activity$PlaceholderFragment">

<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:fastScrollAutoHide="true"
    app:fastScrollAutoHideDelay="1000"
    app:fastScrollPopupBgColor="@color/colorAccent"
    app:fastScrollPopupTextColor="@android:color/primary_text_dark"
    app:fastScrollThumbColor="@color/colorAccent"
    app:spanCount="2"/>

Add support for CoordinatorLayout offset behaviors

When the parent RecyclerView is contained in a ViewGroup with another view whose scrolling behavior causes the RecyclerView to be pushed down, the FastScroll track and thumb moves off-screen with the RecyclerView.

There should be some sort of adjustment to allow the FastScroll track, thumb & scroll-range to remain fixed even when the parent RecyclerView is moved down.

Scrollbar is not displayed if RecycleView is embedded into a NestedScrollView

In the following layout the scroll bar does not appear:

 <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/permission_header"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="16dp"
                android:textAppearance="@style/TextAppearance.AppCompat.Medium"
                android:textStyle="bold"
                tools:text="216 Permissions:"/>

            <com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
                style="@style/FastScrollRecycleView"
                android:id="@+id/permission_list"/>

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

where

<style name="FastScrollRecycleView">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">match_parent</item>
        <item name="fastScrollAutoHide">true</item>
        <item name="fastScrollAutoHideDelay">@integer/scroll_auto_hide_delay_millis</item>
        <item name="fastScrollPopupBgColor">@color/scrolling_popup_background</item>
        <item name="fastScrollPopupTextColor">@color/scrolling_popup_text_color</item>
        <item name="fastScrollThumbColor">@color/scrolling_thumbnail_color</item>
        <item name="fastScrollPopupTextSize">@dimen/scroll_popup_text_size</item>
        <item name="fastScrollPopupBackgroundSize">@dimen/scroll_popup_background_size</item>
    </style>

Code adjustments:

recycleView.setLayoutManager(new LinearLayoutManager(getContext()));
recycleView.setNestedScrollingEnabled(false);

Library version used: 1.0.11

fastScrollAutoHide is not respected

I want to disable autohide and always show the scrollbar/ fastscroll like Whatsapp Contacts. However, app:fastScrollAutoHide="false" has no effect, it's always auto-hide!

I'm using Android Support library 23.4.0

FastScroll lag

When dragging the FastScroll handle with many items in the RecyclerView (1000+), the scrolling becomes incredibly laggy.

Not support StaggeredGridLayoutManager

LinearLayoutManager and GridLayoutManager are OK, but StaggeredGridLayoutManager is not.
The error occurs here:
com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView

...
LinearLayoutManager layoutManager = ((LinearLayoutManager) getLayoutManager());
...

Not working when each item of the recyclerview has two elemnts

I followed your tutorial but the problem is that each item in my recyclerview has two elements (in other words two TextViews) and now I get an error on this part :
@NonNull @Override public String getSectionName(int position) { return String.valueOf(position); }
PS: I want to set the scrollbar on one element only not the two of them

Scroll jumps with GridLayoutManager.SpanSizeLookup

Scroll position jumps with header and GridLayoutManager(context, 2).
final GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 2);
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
    @Override
    public int getSpanSize(int position) {
         return mFileModelCardAdapter.isHeader(position) ?
            gridLayoutManager.getSpanCount() : 1;
    }
});
mRecyclerView.setLayoutManager(gridLayoutManager);

MeasurableAdapter interface does not exist

Hello
I use compile 'com.simplecityapps:recyclerview-fastscroll:1.0.15' in my app.gradle but I can not use FastScrollRecyclerView.MeasurableAdapter interface like sample app for my adapter.
Please guid me, Thanks a lot

Merge from MaterialScrollBar library

Hi there. Author of the MaterialScrollBar library here: https://github.com/krimin-killr21/MaterialScrollBar

I'd like to have your blessing to fork your library and start working on a library merge. Your lib is much more efficient codewise than mine hence why I'm suggesting using yours as a base. The two libs are so similar I think it would do us and the community good to work together. All I'd ask is for commit privileges if the pull request gets approved and then I'd depreciated my lib and redirect here. I'd work on integrating the following features:

  1. Date and custom-content pop-ups/indicators in addition to your current pop-up.
  2. Google launcher / Google PDF viewer style draging handle (see DragScrollBar from my lib) as an alternative style option.
  3. It looks like I may also be able to move all the custom logic from the FastScrollRecyclerView class into the FastScroller class and thus allow use of the lib with custom recylerViews which extend the vanilla class. We could then add XML and programmatic attachment as seen in my lib to associate the scroll bar and the recylerViews together. If you know of any logic in the class that would prevent this let me know.
  4. Any other features I think off.

Other than these changes we'd keep all of your code.

Regards

How to hide FastScroll

Hi , how to hide and show fastscroller by a method like this ?

FSV.showFastScroller(false);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.