EverythingMe / overscroll-decor

Android: iOS-like over-scrolling effect applicable over almost all scrollable Android views.
BSD 2-Clause "Simplified" License
2.85k stars 400 forks source link

Overscrolling not working #9

Closed dadu1 closed 8 years ago

dadu1 commented 8 years ago

Sometime for some scrollview layouts or Recyclerview when we scroll to bottom overscroll not works from bottom. Overscroll from top of the view works well in every scenario.

d4vidi commented 8 years ago

Hey @dadu1. How about sending over a snippet of your code and XML associated with the RecyclerView and over-scrolling effect? That would really help in trying to assist.

Also, could you please describe the scenario better? if you're referring to 'auto' over-scrolling (i.e. due to a 'fling' reaching the bottom) -- that's not supported yet. Alternatively, could you also tell me whether when at the bottom end - as the problem takes place, the over-scrolling seizes to respond altogether, or just for a one or very few touch gestures?

dadu1 commented 8 years ago

Hi @d4vidi actually I gone through your code. I found where problem reflects. You have one class RecyclerViewOverScrollDecorAdapter in which there is one method isInAbsoluteEnd(). which is currently not accurate. mLayoutManager.findLastCompletelyVisibleItemPosition() for complex recycler views with mutiple view holders and in some other scenarios this method doesn't return correct complete visible position and it is not adapter's last item postition it returns -1 in some cases.

So I found better way for this method and it works for every situations:

 if(mLayoutManager.getOrientation()==LinearLayoutManager.HORIZONTAL)
            {
                if(mRecyclerView.canScrollHorizontally(1))
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                if(mRecyclerView.canScrollVertically(1))
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
d4vidi commented 8 years ago

Nice! Thanks for the deep inspection! Have you tried your code -- does it fix the problem? I promise to look into it but I'd greatly appreciate a pull request on your behalf... :-)

Thanks!!!

dadu1 commented 8 years ago

Hi @d4vidi I tried as above way and it solved my problem. The main problem was isInAbsoluteEnd() returns false even if my recyclerview reached at bottom so over scrolling not works because in OverScrollBounceEffectDecoratorBase class there is one inner class IdleState and in that class

if ((mViewAdapter.isInAbsoluteStart() && mMoveAttr.mDir) ||
                (mViewAdapter.isInAbsoluteEnd() && !mMoveAttr.mDir))

in this condition was not satisfied due to isInAbsoluteEnd return false and I changed its implementation as I suggested and now it works!!!

d4vidi commented 8 years ago

Please try release 1.0.3 and see if it works. If it doesn't - please resubmit. Thanks!

HasanMhdAmin commented 5 years ago

I faced the same issue here with v1.0.4