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 dont return the first position when the user scroll at (0,0) position #57

Closed
mr-gilberto opened this issue Mar 10, 2019 · 1 comment

Comments

@mr-gilberto
Copy link

I have the next problem, I have this view, the problem is when the user scroll at first element, when the "top" of the view is reached (0,0) the GravitySnapHelper.SnapListener dont return the position, this only happens if the view is scrolled at "(0,0) ", but if i scroll at "(0, .1)" for example(only a little bit of scroll in y position) , it wokrs fine. . The callback is not fired, when the view is in their original state

Here is the layout:

  private fun setProductsAdapter() {
        val layoutManager = LinearLayoutManager(activity)
        layoutManager.isItemPrefetchEnabled = false
        recyclerViewGallery.layoutManager = layoutManager
        recyclerViewGallery.setHasFixedSize(true)

        productImageAdapter = ProductImageAdapter(product)
        recyclerViewGallery.adapter = productImageAdapter

        GravitySnapHelper(Gravity.TOP, false,
            GravitySnapHelper.SnapListener { position ->

                drawGalleryIndicator(position)
              
            }).attachToRecyclerView(recyclerViewGallery)

        drawGalleryIndicator(0)
    }
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:foreground="?attr/selectableItemBackground"
    android:orientation="vertical">

    <ImageView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/iv_product"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        app:srcCompat="@drawable/ic_perro_logo_w_letters">

    </ImageView>
</androidx.cardview.widget.CardView>
@mr-gilberto mr-gilberto changed the title GravitySnapHelper dont return the first position when at (0,0) position GravitySnapHelper dont return the first position when the user scroll at (0,0) position Mar 10, 2019
@rubensousa
Copy link
Owner

Fixed on 2.1.0

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

No branches or pull requests

2 participants