FastAdapter v5.0.0-a06 Release Notes

Release Date: 2020-02-15 // 7 months ago
  • ๐Ÿ›  Fixes

    • ๐Ÿ‘ to further migrate towards a better separation of responsibilities we have introduced a new interface which will describe the logic for creating the ViewHolder the IItemVHFactory.
    • To complete this interface there is now a new BaseItem and ModelBaseItem to allow splitting item logic, and ViewHolder creation logic.
    • ๐Ÿ—„ The old AbstractItem and ModelAbstractItem are now deprecated in favor of the newer approach
    • The IItem interface no longer contains the Factory logic
    • It is still possible to implement items "the old way" by using the AbstractItem or by providing the IItemVHFactory beside the IItem interface, and also the IItemViewGenerator if needed

    Migration

    OLD

    If the Item implementation looked like:

    class SimpleImageItem : AbstractItem\<SimpleImageItem.ViewHolder\>() { override val type: Int get() = R.id.fastadapter\_simple\_image\_item\_id override val layoutRes: Int get() = R.layout.simple\_image\_item override fun bindView(holder: ViewHolder, payloads: MutableList\<Any\>) { ... } override fun unbindView(holder: ViewHolder) { } override fun getViewHolder(v: View): ViewHolder { return ViewHolder(v) } class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { var view: FrameLayout ... } }
    

    ๐Ÿ†• NEW

    โ™ป๏ธ It should be refactored to look like:

    class SimpleImageItem : BaseItem\<SimpleImageItem.ViewHolder\>() { override val type: Int get() = R.id.fastadapter\_simple\_image\_item\_id override val factory: IItemVHFactory\<ViewHolder\> = SimpleImageItemFactoryoverride fun bindView(holder: ViewHolder, payloads: MutableList\<Any\>) { ... } override fun unbindView(holder: ViewHolder) { ... } class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { var view: FrameLayout } }object SimpleImageItemFactory : BaseItemFactory\<SimpleImageItem.ViewHolder\>() { override val type: Int get() = R.id.fastadapter\_simple\_image\_item\_id override val layoutRes: Int get() = R.layout.simple\_image\_item override fun getViewHolder(v: View): SimpleImageItem.ViewHolder { return SimpleImageItem.ViewHolder(v) } }