当前位置:网站首页>Slide the receleview horizontally to the far right to listen to the page loading function
Slide the receleview horizontally to the far right to listen to the page loading function
2022-06-11 05:36:00 【Cockroach bully BBQ】
Close test available
thank :https://www.jianshu.com/p/5eb2de368ea0
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
// Used to mark whether it is sliding to the left
private boolean isSlidingToLeft = false;
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
// When not sliding
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
// Get the last fully displayed itemPosition
int lastItemPosition = manager.findLastCompletelyVisibleItemPosition();
int itemCount = manager.getItemCount();
// Judge if it's sliding to the last item, And it slides to the left
if (lastItemPosition == (itemCount - 1) && isSlidingToLeft) {
// Load more
onLoadMore();
}
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
// dx Greater than 0 Indicates that you are sliding to the left , Less than or equal to 0 Indicates sliding or stopping to the right
isSlidingToLeft = dx > 0;
}
/**
* Load more callbacks
*/
public abstract void onLoadMore();
}
边栏推荐
- SQLite one line SQL implementation updates if there is one, inserts if there is none, multiple conditions, complex conditions
- ReferenceError: server is not defined
- Bit operation marks multiple switches with one parameter
- 35. search insertion position
- Combing route - Compaction Technology
- Poverty has nothing to do with suffering
- 自定义View之基础篇
- In the future, how long will robots or AI have human creativity?
- 点击图标不灵敏咋整?
- mysql字符串转数组,合并结果集,转成数组
猜你喜欢

Redis setup (sentinel mode)

Games101 job 7-path tracing implementation process & detailed interpretation of code

es-ik 安装报错

点击图标不灵敏咋整?

Multithreading tutorial (XXVII) CPU cache and pseudo sharing

自定义View之基础篇

If the MAC fails to connect with MySQL, it will start and report an error

Analyzing while experimenting - memory leakage caused by non static inner classes

Click the icon is not sensitive how to adjust?

mysql字符串转数组,合并结果集,转成数组
随机推荐
智能门锁为什么会这么火,米家和智汀的智能门锁怎么样呢?
Zed2 running vins-mono preliminary test
Section II: structural composition characteristics of asphalt pavement (2) structural layer and performance requirements
Conversion relationship between coordinate systems (ECEF, LLA, ENU)
1.使用阿里云对象OSS(初级)
Section II: structural composition characteristics of asphalt pavement (1) structural composition
Swap numbers (no temporary variables)
Feynman learning method
PageHelper page 2 collections in the same interface
Start the project using the locally configured gradle
Section I: classification and classification of urban roads
如何让灯具智能化,单火、零火智能开关怎么选!
Opencv learning path (2-3) -- Deep parsing imshow function
Wechat applet uploads the data obtained from database 1 to database 2
[entry level basics] node basic knowledge summary
Customize the layout of view Foundation
Deep learning distributed training
Minimize maximum
Linked list de duplication
【深入kotlin】 - Flow 进阶