I find most of the material is about discussing adding "pull to refresh" in the area below AppBarLayout, such as SwipeRefreshLayout, I wonder how to do this in the AppBarLayout, which means:
When pull down, the pull-to-refresh indicator appeaars in the AppBarLayout.
how to implement this? Thanks
=================UPDATE===================
I finally worked it out on my own way. Here is the video link recording the simple UI.
The key point is I rewrite the appbarlayout-spring-behavior from github. It's really helpeful. Simply put, I rewrited the AppBarLayoutSpringBehavior, adding a Pull-To-Refresh-Callback when draging, and add some logic to displaying the pull-to-refresh animation prevent simplely animating back to original state. After sometime, then I tell the behavior to animate back.
Though the rewriten code seems ugly, but it seems feasible. I will refactor my code to make it clean and modular
I have wrote one nestrefresh repo which you can add pull refresh for the header same to AppBarLayout. You can add pull to refresh for child in ViewPager or pull to load more. You can use ChildCoordinatorLayout in my repo to wrap AppBarLayout if you want to use AppBarLayout only. But when scroll AppBarLayout can not refresh because of AppBarLayout has not send scroll event to parent. So you can try RefreshBarLayout in the repo.
I finally worked it out on my own way. Here is the video link recording the simple UI.
The key point is I rewrite the appbarlayout-spring-behavior from github. It's really helpeful. Simply put, I rewrited the AppBarLayoutSpringBehavior, adding a Pull-To-Refresh-Callback when draging, and add some logic to displaying the pull-to-refresh animation prevent simplely animating back to original state. After sometime, then I tell the behavior to animate back.
Though the rewriten code seems ugly, but it seems feasible. I will refactor my code to make it clean and modular
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With