Jamshid-M / IGRefreshLayout

Instagram like refresh layout
48 stars 12 forks source link

Can't show AppBarLayout upon scrolling up #4

Open vidicunt opened 4 years ago

vidicunt commented 4 years ago

Issue 1.:

This is my layout:

    <LinearLayout>
        <androidx.coordinatorlayout.widget.CoordinatorLayout>

            <com.google.android.material.appbar.AppBarLayout>
                <androidx.constraintlayout.widget.ConstraintLayout>
                                    --- APPBARLAYOUT CONTENT ---
                </androidx.constraintlayout.widget.ConstraintLayout>
            </com.google.android.material.appbar.AppBarLayout>

            <FrameLayout>
                <uz.jamshid.library.IGRefreshLayout>

                    <androidx.recyclerview.widget.RecyclerView
                        android:id="@+id/recycler_list" />

                </uz.jamshid.library.IGRefreshLayout>
            </FrameLayout>

        </androidx.coordinatorlayout.widget.CoordinatorLayout>
    </LinearLayout>

The appbarlayout scrolls with these flags: app:layout_scrollFlags="scroll|snap|exitUntilCollapsed. The IGRefreshLayout overrides this scroll, and instead triggers the refresh animation, without letting the appbarlayout show itself first. Scrolling a bit down, and then up again fixes this issue.

Issue 2.: The same layout, but with the IGRefreshLayout as the top element has this same effect + when scrolling up, the views from the recyclerlayout are not recycled, and the IGRefreshLayout animation triggers again.

Jamshid-M commented 4 years ago

Hello For your first issue just add app:layout_behavior="@string/appbar_scrolling_view_behavior" into FrameLayout which covers RefreshLayout

Jamshid-M commented 4 years ago

For second issue the only way to fix this issue with appbar is to set listener for AppBarLayout

appBar.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset -> //swip is IGRefreshLayout instance swipe.isEnabled = verticalOffset == 0 })

Case with Coordinator and AppBarLayout not implemented yet

vidicunt commented 4 years ago

Unfortunately for the second case the refresh layout scrolls up and remains there, in the disabled state without ever coming back down

Jamshid-M commented 4 years ago

Everything works as a charm in my device, maybe you miss something, here is my code image image