github mikepenz/FastAdapter v5.0.0-a06

latest releases: v5.7.0, v5.6.0, v5.5.1...
pre-release4 years 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> = SimpleImageItemFactory

    override 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)
    }
}

Don't miss a new FastAdapter release

NewReleases is sending notifications on new releases.