先看效果图
主要处理的地方:
1、recyclerview中adapter的item个人可以无限轮询.
2、recyclerview自动滑动
3、手指按下时滑动停止,手指抬起后继续自动滑动
public class autopollrecyclerview extends recyclerview {
private static final long time_auto_poll = 16;
autopolltask autopolltask;
private boolean running; //标示是否正在自动轮询
private boolean canrun;//标示是否可以自动轮询,可在不需要的是否置false
public autopollrecyclerview(context context, @nullable attributeset attrs) {
super(context, attrs);
autopolltask = new autopolltask(this);
}
static class autopolltask implements runnable {
private final weakreference mreference;
//使用弱引用持有外部类引用->防止内存泄漏
public autopolltask(autopollrecyclerview referenc