Closed zhangwen9229 closed 7 years ago
Actually, when you call callback(rowData, options)
inside the onFetch()
method, the state of the listview will be set to {isRefreshing: true}
. Then, if you want to terminate the refreshing state manually, you can call the stopRefresh()
method. I suggested you put this method in your catch block, like:
onFetch = async(page = 1, callback, options) => {
try {
........//your code
callback(rowData, options);
} catch (err) {
this._listView.stopRefresh(); //this will be called when you encounter a network error or timeout
console.log(err);
}
};
@gameboyVito ,thank you for your reply . ^_^ I think,I didn't describe my real thought.But your reply also help me to get more info . I want to change refreshableTitle. when I release finger , the refreshableTitle changed to 'refreshing...'.
^_^ Do you understand me?
@gameboyVito Hello,I think i have resolve the problem.But this is not good idea I think. The code I wrote: onFetch = async(page = 1, callback, options) => { try { this.setState({refreshableTitle:'刷新中...'}) await this.sleep(1000); ...... callback(rowData, options); this.setState({refreshableTitle:'数据已刷新'}) await this.sleep(1000) this.setState({refreshableTitle:'下拉刷新'})
} catch (err) {
console.log(err);
}
};
Do you think about it? ^_^
I see, good suggestion. Wait for a minute. I will push a new version to support this feature.
wow , nice. Hope next version.
Hi, I have pushed a new version in NPM v1.0.20 with for new props
refreshableTitleWillRefresh
refreshableTitleInRefreshing
refreshableTitleDidRefresh
refreshableTitleDidRefreshDuration
And I have updated my README file, please also check that for further information, like how to use them.
OK,thanks. I will try it later.
@gameboyVito Hello,I think there is some problem with the new version,v1.0.20. The code I wrote is : refreshableTitle = 'pull to refresh' refreshableTitleWillRefresh = 'pull to refresh' refreshableTitleInRefreshing = 'refreshing...' refreshableTitleDidRefresh = 'data had refreshed' refreshableTitleDidRefreshDuration = {1000} but when using,the sequence look not right. When get in the page first time, quick to exec pull to refresh , you will see refreshableTitleDidRefresh--['data had refreshed'],first eyes. Not the refreshableTitle.
I think we reference https://github.com/greatbsky/react-native-pull.
please check it. And I think the problem lies with refreshableTitleDidRefreshDuration. If we can add the code changed the title to 'pull to refresh',when state at finger pulling.
Thanks for your reply. The refreshableTitleDidRefreshDuration
just a simple and quick hack for your requirement. Setting it to a small value will change the title back to the default one more quickly. In fact, it's just a simple setTimeout
method and I didn't handle it with the panResponder
. I'm kind of busy now, maybe you can send a Pull-request for me to have a look. Thanks.
Let me think about it. O(∩_∩)O I close this issue first.
I think I know how to implement this new feature in a correct way, but it may take a few days with a little bit complex. I am working on it.
@gameboyVito I will think and think. I am a newer for react-native. So it's hard for me at present. ^_^
Hi, I have upgraded this module to v2.0.2 and implemented your thought. Please check the lastest Wiki and thanks for your suggestion.
@gameboyVito I see your message just now. I try the new version right now.
@gameboyVito genius,very nice refresh. I like it. I try it more next. Thank you for your help.
@gameboyVito Hello,I find a new problem. when I scroll listView from bottom to top ,quickly. The refreshControl will come out easy. Can you make it hard?
Which version are you using?
Did you mean the refreshView just stuck there and won't hide itself automatically? If it is, that's a known issue. Try updating to v2.0.5, that bug should be fixed in the latest version. By the way, you can just speak in Chinese ^_^
@gameboyVito 太好了,早说啊。哈哈,还是中文聊得6
@gameboyVito 我已经升级了 "react-native-ultimate-listview": "^2.0.5" 但是,在Android上,下拉滑动快的时候,会出现 卡在 下拉刷新 状态
ios的话应该是没问题的,但是android的listview是不允许bounce的,所以我只能是默认在listview顶端插入一个自定义的高度90的refreshview,然后默认下滑90dpi。我想android偶尔会卡住是因为调用了onMomentumScrollEnd={this.onScrollEndDrag}
这个callback,这个函数是在滑动的动画结束时调用的,当用户快速从下面滑回顶端时,会调用这个callback反弹回90dpi的起始位置避免刷新。onScrollEndDrag
这个则是松开手指的时候的callback。之所以卡住,我调试的时候发现这个卡住的时候 onMomentumScrollEnd
会无限循环调用,我想是因为你下拉快的时候,触发了下滑动画,而且refreshview的state也正好刷新, 导致无限循环。我暂时也没想到怎么解决android的问题。也许可以用个timer判断0.5秒之内这个callback被调用了超过10次就自动下滑回91dpi。
好的,实在不好弄,安卓,我就用原生的 下拉刷新 😁
我个人觉得安卓默认的Material Design的刷新效果就已经很好了 哈哈
嗯嗯,确实。 先这样吧。O(∩_∩)O~
Hi, as you said before:
在Android上,下拉滑动快的时候,会出现 卡在 下拉刷新 状态
I have pushed a new version 2.0.6 to fix this android problem. Maybe you would like to have a try?
@gameboyVito OK,let me try tomorrow. Thank you for your hardworking.
@gameboyVito 我试了下,不会卡住了。 但是,快速上来,会出现 头部区域 闪烁。😁
@zhangwen9229 Hi, I added a setTimeout to make it asynchronous. I think the problem of flickering is solved. At lease in my perspective, I cannot feel any flickering again ^.^
嗯,我再试试。(^o^)/~ 感谢回复。
hi, please look at the title. what should we do ?
Look forward to reply.