notifyPullToRefreshFinished() fails on android

4 posts, 0 answers
  1. Nick
    Nick avatar
    13 posts
    Member since:
    Jun 2017

    Posted 09 Sep Link to this post

    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

  2. Deyan
    Admin
    Deyan avatar
    2147 posts

    Posted 11 Sep Link to this post

    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.
  3. Nick
    Nick avatar
    13 posts
    Member since:
    Jun 2017

    Posted 02 Oct in reply to Deyan Link to this post

    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;

     

  4. Nikolay Iliev
    Admin
    Nikolay Iliev avatar
    294 posts

    Posted 04 Oct Link to this post

    Hello 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.
Back to Top