New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
实现聊天APP列表,onUpFetch ,重复执行的问题? #1458
Comments
贴代码?我这边按文档上接入,没问题的,
五步 |
@897902334 你是否在外部嵌套的sv? |
@CymChad 我去,我也发现了,开启顶部加载更多只要快速滑动到顶部,就会一直执行请求,直到请求完毕, |
@897902334 你这个逻辑跟 demo 是有出入的,加延迟是因为数据和视图不一定同步,所以最好要加? @guominfang 怎么会一直请求呢,你把数据加到末尾还是头部了,加到头部它不会自动滚动到头部,也就不会继续请求了 |
我怎么掉不出setUpFetchListener这个方法呢? |
@tysheng 会一直加载的情况是这样的:
|
@guominfang 添加新数据之后,视图会自动滚动到顶部吗? |
@tysheng 不会自动滚动到顶部。你不理解我说的, |
@guominfang |
@tysheng 心好累,感觉你不能理解,不清楚你是不是没用到这个功能。 |
@guominfang 他 @tysheng 是这个功能的开发者。。。 |
@FrankKwok @tysheng 额...这样,需要我做个demo,上传吗? |
希望作者 解决一下吧, 一个星期了转眼就过去了··· 好惆怅! 谢谢。 @tysheng |
@tysheng
item_simple布局就是简单的一个TextView
|
@guominfang 我写这个出发点是轻量级,不是跟 load more 这样的,不需要提供头部的加载动画,或者用 原生的 swipe refresh 来代替,像知乎那样 private void autoUpFetch(int positions) {
if (!isUpFetchEnable() || isUpFetching()) {
return;
}
if (positions <= mStartUpFetchPosition/*这边添加 header count 试试*/+getHeaderLayoutCount() && mUpFetchListener != null) {
mUpFetchListener.onUpFetch();
}
} |
@tysheng
这一步的处理,只能处理正常的向上滑动,触发的onUpFetch()的时机。处理不了目前的这个问题。 我觉得问题点是在: 当HeaderView显示的时候,调用mAdapter.addData(0, moreData);添加新数据,就相当于是把新数据插入 |
应该是减,写错了
…On 2017年8月25日周五 10:58 guominfang ***@***.***> wrote:
@tysheng <https://github.com/tysheng>
嗯,我试过,如果不添加HeaderView来显示加载中效果的话,是正常加载的,不会一直执行加载,
private void autoUpFetch(int positions) {
if (!isUpFetchEnable() || isUpFetching()) {
return;
}
if (positions <= mStartUpFetchPosition/*这边添加 header count 试试*/+getHeaderLayoutCount() && mUpFetchListener != null) {
mUpFetchListener.onUpFetch();
}
}
这一步的处理,只能处理正常的向上滑动,触发的onUpFetch()的时机。处理不了目前的这个问题。
我觉得问题点是在:
因为添加了HeaderView --> positions被占用了 0;
列表数据的 positions -->是从 1开始算了。
当HeaderView显示的时候,调用mAdapter.addData(0, moreData);添加新数据,就相当于是把新数据插入
positions ==
1的位置,这样导致了RecyclerView.Adapter()中的onBindViewHolder重新执行,这时候,onBindViewHolder传入的positions
==1,小于了我们mStartUpFetchPosition,所以导致onUpFetch()一直被回调
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1458 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALW_S8dK2bfGwsAer60yPgFPv-SLvZVkks5sbjhRgaJpZM4O6B3T>
.
|
@tysheng 大神, 那到底该怎么写呢 ??? 能不能把demo中的这个功能重新更新一下下呢??? 我还是不懂、 |
@897902334 可以先把 headerview 去掉看看 |
@tysheng 老铁, 我就没有添加过headerview。 还要去掉么 ? |
你的代码逻辑看不太懂,一些设置监听的方法怎么在回调函数里。addData(0,data) 那块用 post 延迟一下试试 |
@tysheng 其实问题的重点已经不是在 触发onUpFetch()方法上了。
而是onBindViewHolder()的执行时机了。 |
是的,其实逻辑很简单
2017-08-25 17:22 GMT+08:00 guominfang <notifications@github.com>:
… @tysheng <https://github.com/tysheng> 其实问题的重点已经不是在 触发onUpFetch()方法上了。
private void autoUpFetch(int positions) {
if (!isUpFetchEnable() || isUpFetching()) {
return;
}
if (positions <= mStartUpFetchPosition && mUpFetchListener != null) {
mUpFetchListener.onUpFetch();
}
}
而是onBindViewHolder()的执行时机了。
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1458 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALW_S6zT2NP4MsHZX0TyuZesSihPDqtGks5sbpJAgaJpZM4O6B3T>
.
|
监听 reyclerview 的滑动也可以做到,只是不『自动』 |
@tysheng 嗯,估计目前的实现方式,不能使用headerview, |
把那个值改一下好了
…On 2017年8月25日周五 19:27 guominfang ***@***.***> wrote:
@tysheng <https://github.com/tysheng> 嗯,估计目前的实现方式,不能使用headerview,
我这边去掉headerview,是正常的
@897902334 <https://github.com/897902334>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1458 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALW_S0JY8KSWbDaybYvv0sOEcHWyqvYxks5sbq-6gaJpZM4O6B3T>
.
|
@tysheng 我试过mAdapter.setStartUpFetchPosition(0); |
@897902334 @guominfang @tysheng 问题解决了没? |
我这边,没事实际的解决办法。不添加HeaderView,就能正常 |
恩,看你们反复沟通了很多,应该都聊透了。有问题可以再提。 |
@guominfang 不要直接调这一句,把mAdapter.addData(0, moreData)内的notifyItemRangeInserted(position + getHeaderLayoutCount(), newData.size()); |
我按照demo里的写法,照着谢了, 但是 首次运行 他就不停的执行onUpFetch 直到请求到最后一页 他才停止执行, 为啥啊? 我在回调方法里头 调用了adapter.setUpFetching(false); 而且 在onUpFetch 也调用了setUpFetchEnable(true), 但他就是不按照demo那种效果来执行 不知道为啥!!!
The text was updated successfully, but these errors were encountered: