thorbenprimke / realm-recyclerview

A RecyclerView that is powered by Realm and lots more
555 stars 151 forks source link

RecyclerView does not update information #78

Closed Heman1955telewormus closed 5 years ago

Heman1955telewormus commented 8 years ago

After updating the information using a transaction, the recycler view does not automatically update.

realm.executeTransactionAsync(new Realm.Transaction() {
                @Override
                public void execute(Realm realm) {
                  //Restaurant is just a model with an id and a name. The name is being updated
                    realm.copyToRealmOrUpdate(restaurant);
                }
            }, new Realm.Transaction.OnSuccess() {
                @Override
                public void onSuccess() {
                    // This method must be called or else the recycler view is not automatically updated. Is this the correct behaviour? 
                    restaurantRealmAdapter.notifyDataSetChanged();
                }
            }, new Realm.Transaction.OnError() {
                @Override
                public void onError(Throwable error) {

                }
            });

In the layout xml file, I have already set app:rrvIsRefreshable="true" and during object creation, the automatic update works fine.

davinic commented 8 years ago

I experienced this when I had the adapter set to animate as well as auto-refresh. Passing false to the animateResults parameter fixed it for me. I haven't had a chance to dig into why it's happening.

mclark4386 commented 7 years ago

Thanks so much for both posting this issue and posting what fixed it for you! Hopeful this is an easy fix...