10 Android Old driver teaches you to create a unique refresh loading framework

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.