Comments (7)
@kmare - Yes, it should update but because I'm only diffing on the item's id (primary key) which I'm assuming remains the same in your case and thus the notifyItemChanged
is not triggered.
If you have automatic updates enabled, then whenever the Realm changes the update is received by the adapter. In order to filter out updates not related to the Realm in the adapter, I'm using the ids to detect change and trigger the animations.
I need to see about an efficient way to detect the change when an item's id is the same but the contents are changed. Maybe hashCode could help.
from realm-recyclerview.
Committed 49a7a34
from realm-recyclerview.
@kmare - I added a new optional parameter to the adapter to specify a columnName that should be used for the "id" that is used for diffing the realm changes.
I tried hashCode but that didn't work because the hashCode didn't change when making an update to a Realm object. It also cannot be overriden to have a custom hashCode.
I updated the LinearLayout example so that if you long press a row, it updates the text and this triggers the automatic update and notifyItemChanged
for that item.
from realm-recyclerview.
Hi @thorbenprimke , thank you for working on this. I implemented what you said, but I think it's not the right way to do it (I might be totally wrong of course and didn't understand exactly what to do). I'll try to explain using your example: so if set the "quote" column to the adapter, it works. But that means that if I have more fields in my model that might change, the notifyItemChanged() won't be called on them. So I believe what's needed to be set in the adapter is actually the "id" (PrimaryKey) which remains constant and any change made to any other field should trigger the notifyItemChanged().
Not sure I explained properly the issue.
from realm-recyclerview.
Yes, you should ideally have a column that would change whenever anything on the object changes.
Since posting my last response, I actually changed it back to always use the primaryKey and have an optional second column (202b590).
In the example, I'm using "quote" for the optional column.
However, in a real application, it probably should be something like "lastChangedTime". This way it is guaranteed that the row changed is detected.
I hope this clears up any confusion. The whole "keeping track of the ids" is simply to work around the fact that the realm change notifications don't include any information on what has changed. Once this is fixed / added, the "ids" and "diff code" can be removed.
from realm-recyclerview.
You're totally right, didn't realize the adapter parameter was about the second optional column (seemed weird at first, I should have looked at the code a bit more).
Thank you!
from realm-recyclerview.
No, worries. Thanks for raising this issue initially.
from realm-recyclerview.
Related Issues (20)
- Is it possible to animate RealmRecycleView when i change sort directional?
- example app ArrayIndexOutOfBoundsException: rowIndex > available rows: 2 > 2
- Realm recycler view not refreshing on first insert HOT 1
- How to Make Recycler View show rows from bottom HOT 1
- java.lang.NullPointerException null object reference in Fragment
- Can I group by any field? HOT 1
- Please update to Realm Java 3.0.0
- Can't create a RealmRecycleView Programmatically
- Realm Recyclerview not working with Realm 3.5.0 HOT 1
- Error:(39, 14) Failed to resolve: com.github.thorbenprimke:realm-recyclerview:0.9.25 HOT 1
- Doesn't work with android studio 3.0
- How can we get the LayoutManager? HOT 2
- Enable swipe to delete only in one direction?
- Need to draw background with an icon when the user swipes an item
- Fatal signal 11 while deleting object from Realm
- How to scroll to position not softly?
- how to fire loadmore after fetching and showing every 100 records from realm HOT 1
- Issues When Having Multiple View Types HOT 1
- Attempting to use Realm-recyclerview with Object Server.... HOT 4
- Size APK HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realm-recyclerview.