When the RadListView.notifyPullToRefreshFinished() function is called from within a then-callback on the android platform, the call is ignored and the listview becomes unresponsive; the progress spinner also continues to spin. I have the following workaround, but it would be nice if this wasn't necessary:
public onPullToRefreshInitiated(args: ListViewEventData): void {
this
.reloadUpcoming().then(_ => args.object.notifyPullToRefreshFinished());
// performing this within a then-callback doesn't work on android, so do it again
if
(isAndroid) {
args.object.notifyPullToRefreshFinished();
}
}
private async reloadUpcoming(): Promise<void> {
this
._upcomingSessions.length = 0;
let sessionsHosting: Array<Session>;
sessionsHosting = await
this
.sessionService.getUpcomingSessionsForHost(Config.userId);
sessionsHosting.forEach(s =>
this
._upcomingSessions.push(s));
}
If I omit the notifyPullToRefreshFinished() call from the then-callback, then on iOS the listview locks up upon pull-refresh. Since the above workaround works for me, I'm not to worried about this. But I think it's worth fixing for others since it took me a bit to figure out the workaround.
Thanks
6 Answers, 1 is accepted
Thanks for writing and for the provided snippet.
I have tried reproducing the issue with a similar scenario on my side without success.
Would it be possible if you attached your project or a stripped out version of it that reproduces the glitch so that I can directly take a look and see how I can help?
Thanks!
Regards,
Deyan
Progress Telerik
I was able to solve this by switching to an ObservableArray from a simple Array.
However, on iOS the pullToRefreshInitiated event is raised twice, which caused issues for the ObservableArray (the adds and removes were interleaved from both contexts that were responding to the event). I solved that issue by keeping a component-local flag to keep from responding to there was already a response in-progress:
public onPullToRefreshInitiated(args: ListViewEventData): void {
// iOS hits this event twice, so guard against that
if (this._reloadInProgress) { return; }
this._reloadInProgress = true;
// respond to event
this._reloadInProgress = false;
Glad to hear that you have already found a solution to your iOS issue by using a boolean flag.
However, the issue with the pullOnRefresh callback being triggered twice is not reproducible on our side. If possible, please send us a sample project that can fully reproduce this case so we could investigate further.
Regards,
Nikolay Iliev
Progress Telerik
I had same problem.
And I solved it by next steps on PullToRefresh initiated:
- Load data
- call notifyPullToRefreshFinished()
- update list with new data
Example:
onPullToRefreshInitiated(args: ListViewEventData) {
var
that =
new
WeakRef(
this
);
that.get().loadData().then((data)=>{
args.object.notifyPullToRefreshFinished();
that.get().set(
"data"
, data);
});
}
Thank you for providing the solution for the community!
Regards,
Nikolay Iliev
Progress Telerik
I would like to let you know that we are closing UI for NativeScript Forum section in Telerik Admin in favor of NativeScript forum.
Since UI for NativeScript is free for using we consider that the best place for discussions and for questions will be the official NativeScript forum.
Thank you in advance for cooperation.
Regards,
nikolay.tsonev
Progress Telerik