An example of Hannes Dorfmann AdapterDelegate pattern impl.
The reason of this project is to show how simple is to design and write your own "AdapterDelegate" implementation.
There an example of using AdapterDelegate in simple Android project :sample.
- don't put
adapter
intoviewmodel
. it's ok to have link to viewmodel in adapter, but adapter shouldn't have link to viewmodel, bcs viewmodel have different scope and alive longer - each item should be possible to be compared - it's the same unit and it was changed. Easy way for it, set for same unit key
layout id
and for was changed make delegatedata class
and useAny::equals
- remember, if you don't clear listeners on
onViewRecycled/onUnbindViewHolder
, it could affect ononBindViewHolder/onBind
DiffUtil
work rly slow on big diffs- don't make Entity an RecyclerViewDelegate for reusabilyty
- RecyclerViewDelegate has access to event listener only on bind state. otherwise user may create leak by refs viewmodel as event listener and delegates in livedata