Releases: sockeqwe/AdapterDelegates
Releases · sockeqwe/AdapterDelegates
4.3.2
4.3.1
4.3.0
4.2.0
4.1.1
Added some shortcuts / convenience functions (and properties) for kotlin DSL. Instead of calling itemView.context
you now have direct access to the following fields and functions:
- context (backed property)
- getString(@StringRes resId: Int): String
- getString(@StringRes resId: Int, vararg formatArgs: Any)
- getColor(@ColorRes id: Int)
- getDrawable(@DrawableRes id: Int)
- getColorStateList(@ColorRes id: Int)
Overall this minor release just reduces a bit more typing for you as you now can do something like this:
fun catDelegate() = adatperDelegate<Cat, Animal>(R.layout.cat) {
...
bind {
icon.drawable = getDrawable(R.drawable.cat) // instead of itemView.context.getDrawable()
}
}
4.1.0: Kotlin DSL
Added a Kotlin DSL to create AdapterDelegates through a fluend DSL. There are actually 2 DSL artifacts:
- adapterdelegates4-kotlin-dsl:
fun catAdapterDelegate(itemClickedListener : (Cat) -> Unit) = adapterDelegate<Cat, Animal>(R.layout.item_cat) {
val name : TextView = findViewById(R.id.name)
name.setClickListener { itemClickedListener(item) }
bind {
name.text = item.name
}
}
- adapterdelegates4-kotlin-dsl-layoutcontainer:
Pretty much the same asadapterDelegate
but uses kotlin android extension'sLayoutContainer
and the generated synthetic properties. Thus, you dont have to write anyfindViewById()
.
fun catAdapterDelegate(itemClickedListener : (Cat) -> Unit) = adapterDelegateLayoutContainer<Cat, Animal>(R.layout.item_cat) {
name.setClickListener { itemClickedListener(item) } // name is imported from kotlinx.android.synthetic.main.item_cat.name
bind {
name.text = item.name
}
}
Read the README for more details how to use it.
4.0.0
3.1.0
3.0.1
3.0.0
AdapterDelegate
is now an abstract class (was a interface formerly)- Added the following methods to AdapterDelegate:
onBindViewHolder(@NonNull T items, int position, @NonNull RecyclerView.ViewHolder holder, @NonNull List<Object> payloads);
: This method will be called for bothadapter.notifyItemChanged()
with or without payload. In Version 2.x of this library there was only one methodonBindViewHolder(@NonNull T items, int position, @NonNull RecyclerView.ViewHolder holder)
. This one (with additional payload parameter) replaces the old one.onViewRecycled(ViewHolder holder)
: Called when ViewHolder has been recycledonFailedToRecycleView(ViewHolder holder)
: Called when ViewHolder couldn't be recycledonViewAttachedToWindow(ViewHolder holder)
: Called when View (of ViewHolder) has been attached to windowonViewDetachedFromWindow(ViewHolder holder)
: Called when View (of ViewHolder) has been detached from window
- changed visibility modifiers of methods of
AdapterDelegate
toprotected
(formerlypublic
before because of interface)