This is a migrated thread and some comments may be shown as answers.

notifyPullToRefreshFinished() fails on android

6 Answers 63 Views
ListView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nick
Top achievements
Rank 1
Nick asked on 10 Sep 2017, 01:24 AM

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

Sort by
0
Deyan
Telerik team
answered on 11 Sep 2017, 07:50 AM
Hi Nick,

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
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
0
Nick
Top achievements
Rank 1
answered on 02 Oct 2017, 05:29 AM

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;

 

0
Nick Iliev
Telerik team
answered on 04 Oct 2017, 08:23 AM
Nick,

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
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
0
Павло
Top achievements
Rank 1
answered on 24 Jan 2018, 10:03 AM

I had same problem.

And I solved it by next steps on PullToRefresh initiated:

  1. Load data
  2. call notifyPullToRefreshFinished()
  3. 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);
    });
}

 

0
Nick Iliev
Telerik team
answered on 24 Jan 2018, 10:39 AM
Hi Pavlo,

Thank you for providing the solution for the community!

Regards,
Nikolay Iliev
Progress Telerik
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
0
Nikolay Tsonev
Telerik team
answered on 29 Jan 2018, 12:33 PM
Hello Pavlo,

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
Did you know that you can open private support tickets which are reviewed and answered within 24h by the same team who built the components? This is available in our UI for NativeScript Pro + Support offering.
Tags
ListView
Asked by
Nick
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Nick
Top achievements
Rank 1
Nick Iliev
Telerik team
Павло
Top achievements
Rank 1
Nikolay Tsonev
Telerik team
Share this question
or