Skip to content

An example of Hannes Dorfmann AdapterDelegate pattern impl

Notifications You must be signed in to change notification settings

MrPaperMoon/RecyclerViewDelegate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RecyclerViewDelegate

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.

Just be careful with few moments:

  • don't put adapter into viewmodel. 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 delegate data class and use Any::equals
  • remember, if you don't clear listeners on onViewRecycled/onUnbindViewHolder, it could affect on onBindViewHolder/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

About

An example of Hannes Dorfmann AdapterDelegate pattern impl

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages