thorbenprimke / realm-recyclerview

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

Realm recycler view not refreshing on first insert #102

Closed bacteria323 closed 5 years ago

bacteria323 commented 7 years ago

When I am inserting the first item into the recycler view, it does not automatically refresh. Subsequent insertions are working fine. I have set the automaticUpdate to true. Right now, I am checking if the data only has 1 item and if it is true, I will create a new adapter. Although this works, this does not seem to be the correct way of handing insertions.

new Realm.Transaction.OnSuccess() {
        @Override
        public void onSuccess() {

            RealmResults<Transaction> mTransactions = realm.where(Transaction.class).findAllSorted("id", Sort.ASCENDING);

            if (mTransactions.size() == 1) {
                mRealmAdapter = new TransactionRealmAdapter(getActivity(), mTransactions, true, true, true, "date");
                mRealmRecyclerView.setAdapter(mRealmAdapter);
            }
            mRealmAdapter.notifyDataSetChanged();
}
ordago commented 7 years ago

in issue 70

https://github.com/thorbenprimke/realm-recyclerview/issues/70