Objective
Drop-down refresh and load more, is a more commonly used list of data interaction mode.
Android provides native dropdown refresh container swiperefreshlayout, unfortunately styles cannot be customized.
So I intend to achieve a dedicated. But the drop-down refresh and swipe up, very test of the Android layout with the parent-child touch mechanism, so refer to a popular dropdown refresh project on GitHub
I chose him because it is a class that completes all of the view's adaptations, and it's very thin and powerful.
Demand
Let's refresh and load more controls on the drop-down, with the following requirements:
1: Pull down to refresh, drag to a certain distance, prompt text changes to let go refresh
2: After the refresh completes, the text becomes the refresh completes, the short stay 300 milliseconds prompts the user
3: Then linear acceleration to close the control.
4: Suitable for daytime, night mode different font color.
The final look is like this.
Brief ideas
1: drop-down refresh reference
Https://github.com/Yalantis/Phoenix
Let's streamline the code and keep only what we need.
2: Top Slide load more
We implemented this in the adapter code of the list control, with the following steps:
When you slide to the last item, insert a placeholder data into the array before starting the asynchronous request data, and the adapter is responsible for rendering it into the load style
After the request data is complete, delete the last placeholder data for the array and insert the request data into the array.
Comprehensive use down feeling very good, after all, is our own custom, use also handy, complete code reference Http://git.oschina.net/yso/CNBlogs/tree/master
Android How to customize a drop-down refresh, swipe up to load more containers