Closed zofnk closed 6 years ago
你上面的代码中有业务代码耦合判断。我建议你单独写个测试。不要有业务代码,加载模拟数据打印onLoadMoreRequested方法。如果还有问题再贴测试代码,这样会很好的帮助你发现问题
你试试DataServer延迟几秒返回数据看是否回调onLoadMoreRequested2次
原因找到了 我在adapter构造方法里不知道怎么多加了一句setHasStableIds(true), 麻烦求教下为什么加了这句之后快速上拉会触发2次上拉回调 ..?
跟这句应该没影响吧
我去掉之后就没事了 , 我之后看看能不能复现一个demo试看看 , 到时再反应一下~谢谢了
遇到个很奇怪的问题,不知道从何改起,我这有个列表,上面有2个headview,当快速往上滑动的时候就会触发2次onLoadMoreRequested , 缓慢滑动的话就是正常的触发一次...
初始化适配器 private void initAdapter() { GridLayoutManager scheduleLm = new GridLayoutManager(getContext(), 2); LinearLayoutManager newsLm = new LinearLayoutManager(getContext()); ((SimpleItemAnimator) mRvHome.getItemAnimator()).setSupportsChangeAnimations(false); mSrlHome.setColorSchemeColors(getResources().getColor(R.color.colorPrimary)); mNewsAdapter = new NewsAdapter(null, true); mScheduleAdapter = new HomeScheduleAdapter(null); View imagesBannerView = mInflater.inflate(R.layout.layout_banner_home, null); mBannerView = (HomeImageBanner) imagesBannerView.findViewById(R.id.bannerHome);
处理数据 private void getHomeIndexDatas(boolean isRefresh) { DataServer.homeIndex(mark, page, new LoadingViewCallBack(getContext()) { @Override public void onSuccess(Response response) {
mHomeEntity = new Gson().fromJson(response.body(), HomeEntity.class);
if (mHomeEntity.isShowAlert()) {
if (mHomeEntity.isOk()) {
ToastUtils.successToast(getContext(), mHomeEntity.getMsg());
}
}
if (mHomeEntity.isOk()) {
List newsList = mHomeEntity.getData().getNewsList();
List scheduleList = mHomeEntity.getData().getScheduleList();
mBannerList = mHomeEntity.getData().getSlideshowList();
刷新回调 @Override public void onRefresh() { page = 1; getHomeIndexDatas(true); mSrlHome.setRefreshing(false); mNewsAdapter.setEnableLoadMore(true); }
上拉加载回调 @Override public void onLoadMoreRequested() { mSrlHome.setRefreshing(false); mSrlHome.setEnabled(false); if (mHomeEntity.getData().isHasNext()) { page++; getHomeIndexDatas(false); } else { mNewsAdapter.loadMoreEnd(); } mSrlHome.setEnabled(true); }