kingfisherphuoc / EasyRecyclerViewIndicator

77 stars 12 forks source link

Enhancement Suggestion: Support for LayoutManagers other than LinearLayoutManager #2

Closed siralam closed 5 years ago

siralam commented 6 years ago

I found that your library supports LinearLayoutManager only.

While it makes sense for most cases; but in fact many of us need to find Page Indicators for RecyclerView because we are trying to simulate a ViewPager using a RecyclerView, due to the fact that ViewPager cannot satisfy what we want. In such case, we need to use a custom LayoutManager.

For instance GalleryLayoutManager.

kingfisherphuoc commented 6 years ago

@siralam yes, you're right. I will make it in the future. For your case, there's a workaround that is using AnyViewIndicator. With AnyViewIndicator, you have to set indicator position yourself as below:

verticalIndicator.setItemCount(10); // set the total count of  indicator
verticalIndicator.setCurrentPosition(0); // set the current position of indicator
siralam commented 6 years ago

Thanks for your reply!

Yes, I understand this approach; but this does not work if the select position is settling (e.g. user flings the RecyclerView, we expect the indicator to change rapidly, accordingly)

Although the approach is very different from yours, I turned out implemented the indicator using a custom ItemDecoration, by referencing this blog post.

For your library, if you have a future release, I would suggest creating an interface, and all custom LayoutManagers that wants to support EasyRecyclerViewIndicator would have to implement this interface and override something like int getCentralItemPosition().