After a recent PR, the notes list screen started behaving unpredictably when the set of items is refreshed. A review of the diff is needed to find the causes of the regression.
NoteItem in a RecyclerView.submitList.onPinClick for the note that was actually tapped.ViewHolder reuse, item identity in the list must be determined by a stable unique identifier.Groceries.Groceries is changed to Groceries today;pinned value.Example data refresh scenario:
Before:
1, Groceries, false
2, Ideas, true
3, Travel, false
After:
3, Travel, false
1, Groceries today, false
4, Inbox, true
2, Ideas, true
id should remain selected, even if its title changed and the row moved to another index.onPinClick handler must receive the note from the row that was tapped.DiffUtil must distinguish items by a stable field so the list does not confuse rows during updates.androidx.recyclerview:recyclerview:1.3.2androidx.core:core-ktx:1.13.1androidx.appcompat:appcompat:1.7.0RecyclerView, without ComposesubmitList is called sequentially from one screenActivity or Fragment is enoughUse line comments to explain the problem, its impact, the fix and how to test it.