Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GravitySnapHelper.SnapListener not callback when scroll to first position. #64

Closed
leeprohacker opened this issue May 20, 2020 · 7 comments

Comments

@leeprohacker
Copy link

The issue when I set GravitySnapRecyclerView equal center and also set SnapListener for GravitySnapHelper. So the listener never callback "onSnap" when the recyclerview scrolled to top position and rest positions that working fine.

@rubensousa
Copy link
Owner

The top position won't be called in onSnap if it can't be snapped. This usually happens when you don't have padding or decoration for the top or bottom items.

@leeprohacker
Copy link
Author

@rubensousa rube
I looked into your example, in the row Center with decoration, it's same issue i mentioned above. In fact my project I have added decoration to make item center horizontal. So do you have any advices for me? Thanks

@rubensousa
Copy link
Owner

@leeprohacker I can confirm there's a problem. Sometimes the position 0 isn't dispatched on onSnap. I'll fix this in the next release

@rubensousa
Copy link
Owner

@leeprohacker it should be fixed in the develop branch now. Can you check if now it behaves like you would expect?

@rubensousa
Copy link
Owner

You can check this in your app by installing the version 2.2.1-beta01

@rubensousa
Copy link
Owner

Released on 2.2.1

@Hoalq-0026
Copy link

Hoalq-0026 commented Nov 5, 2020

@rubensousa
Hi!
I have a problem. I can not scroll to the top position when the call method smoothScrollToPosition(0)
in source code:

ryclerviewTopic.apply {
                layoutManager = LinearLayoutManager(context)
               enableSnapping(false)
                adapter = topicAdapter
            }

ryclerviewTopic.smoothScrollToPosition(0)

 <com.github.rubensousa.gravitysnaphelper.GravitySnapRecyclerView
                        android:id="@+id/ryclerviewTopic"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_behavior="@string/appbar_scrolling_view_behavior"
                        app:snapEnabled="false"
                        app:snapGravity="top"
                        app:snapMaxFlingSizeFraction="2"
                        app:snapScrollMsPerInch="50"
                        android:paddingTop="@dimen/_30dp"
                        tools:listitem="@layout/item_home_topic" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants