Code Monkey home page Code Monkey logo

Comments (4)

JamesMcIntosh avatar JamesMcIntosh commented on August 11, 2024 1

Hi Mike, did you breakpoint the code and see the setRefreshing(false) was being called?

I have done a little bit of digging as I had the same problem too. From what I can see is the code for the SwipeRefreshLayout.OnRefreshListener in RealmRecyclerView (hidden at the very bottom of the file) does not turn off the refreshing if the onRefreshListener is null.

If you do have a onRefreshListener set then make sure that it does actually call setRefreshing(false) at the expected time.

https://github.com/thorbenprimke/realm-recyclerview/blob/master/library/src/main/java/co/moonmonkeylabs/realmrecyclerview/RealmRecyclerView.java

I think a solution would be to update the listener as below:

recyclerViewRefreshListener = new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {
        if (!isRefreshing) {
            if (onRefreshListener == null) {
                swipeRefreshLayout.setRefreshing(false);
            } else {
                // listener is in charge of calling setRefreshing(false)
                onRefreshListener.onRefresh();
                isRefreshing = true;
            }
        }
    }
};

from realm-recyclerview.

mikescamell avatar mikescamell commented on August 11, 2024

Ok so i figured out that the realmRecyclerView.setRefreshing(false) is happening too quickly in my code.
I'm guessing it is something to do with the animation only just starting and the speed at which the listener is triggered causing it to not be set to false correctly during the first call.

By adding a delay of 2 seconds to call realmRecyclerView.setRefreshing(false) the refresh animation removes successfully each time.

from realm-recyclerview.

vitas avatar vitas commented on August 11, 2024

have the same issue, something wrong with it.
I have empty adapter, by first refresh it works, by second attempt - endless refreshing animation.

from realm-recyclerview.

mikescamell avatar mikescamell commented on August 11, 2024

Hi @JamesMcIntosh,

Unfortunately the project i was doing this for has taken a back seat but it will come back around eventually. What you've written seems to make sense and I'll try and see if I can throw this in the project this weekend and confirm your solution. Thanks for posting, it's much appreciated.

from realm-recyclerview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.