turing-tech/MaterialScrollBar

Using same RecyclerViewAdapter twice at different fragments MaterialScrollBar wont work on second adapter

duruer opened this issue · 8 comments

Hello, we are using this library on our app. And we have got a little problem.

We have got a MainActivity which it has 3 fragments on ViewPager.

We have got a MediaListAdapter which is RecyclerViewAdapter. We are using this adapter on 2 fragment at the same time. So first fragment works great but second fragment's scrollbar not showen or not working. If you pull from right to left on screen you can see scrollbar on second fragment. But that scrollbar work for first fragment.

I've gotten a sample app to run with the same adapter. Do the recyclerviews share the same ID?

Idk which ID you mean

The ID of the recycler views which share the adapter.

If you mean id on layout, yeah we use same layout for 2 fragment and 2 adapters id are same

The issue ssems to be that the scroll bar in the second fragment is picking out the recyclerView in the first fragment because they share the same ID and it gets confused. You can fix this by manually setting the recyclerView with the .setRecyclerView() method in onCreateView of your second fragment, passing in the correct recyclerView.

Sorry, i don't understand great. We have got one fragment class, we use that as two fragment. I mean in ViewPager we add same fragment twice. That means twice layout, twice code. I can devote which fragment is it in code.

But what do you mean set manually recyclerView. We using Android Databinding.

In the onCreateView method of the fragment that's inserted twice, add the following

RecyckerView rv = view.findViewById(R.id. ___ );
DragScrollBar/TouchScrollBar scrollBar = view.findViewById(R.id.___);
scrollBar.serRecyclerView(rv);

Sorry, i tried but not worked. Still same problem