First we give the following parameters, which are to be used later:
10 Android Old driver teaches you to create a unique refresh loading framework
Since it is refreshing, our scrolling must be before the parent view. So we need to write the x, y values that we need to change in the Onnestedprescroll method.
We need to use the parent view to intercept it. We need to determine if the value of DY is greater than 0, because greater than 0 is the flush operation, and less than 0 is the load operation. Then we need to determine whether the Recyclerview is vertical rather than horizontal.
10 Android Old driver teaches you to create a unique refresh loading framework
Pull-up loading
Above I also said Onnestedprescroll this method to judge Dy<0 is the load operation. So in summary, the code becomes this:
10 Android Old driver teaches you to create a unique refresh loading framework
Finally, we need to do the following when the sub-view slide is finished:
10 Android Old driver teaches you to create a unique refresh loading framework
In fact, the main two methods have been solved, the other to nothing, this way, I put nestedscrolling 8 interface functions and custom Recyclerview out. We have already made reference to them. I hope everyone can achieve their own refresh load. Farewell to Swiperefreshlayout.
Add Headers and Footer
Here we refer to the Addheaderview and Addfooterview from the ListView. The code is as follows:
10 Android Old driver teaches you to create a unique refresh loading framework
Implementation of several interfaces:
10 Android Old driver teaches you to create a unique refresh loading framework
10 Android Old driver teaches you to create a unique refresh loading framework
Custom Recyclerview
Since it is written by the refresh loading framework, there can be no custom layout to put a recyclerview. More trouble, custom one, directly in the inside, and then put a header and footer, there is no need every time a page to refresh all to write a layout. 3 layouts To resolve refreshes and loads for the entire project. Not much to say, the code is as follows:
10 Android Old driver teaches you to create a unique refresh loading framework
10 Android Old driver teaches you to create a unique refresh loading framework
So we've implemented our own refresh loading framework, code I've uploaded to GitHub:
Https://github.com/sw950729/SWPullRecyclerLayout
The use of the method is as follows:
Jcenter:
Compile ' com.angel:swpullrecyclerlayout:1.0.0 '
Maven:
10 Android Old driver teaches you to create a unique refresh loading framework
is still the 2 words. Whatever it takes, we need to know the principle. There is something that does not understand the proposed. can be discussed together.
More
10 Android Old driver teaches you to create a unique refresh loading framework
10 Android Old driver teaches you to create a unique refresh loading framework