Groupie: Failed to add bindings dependency

Created on 22 Aug 2020  路  6Comments  路  Source: lisawray/groupie

Failed to resolve: com.xwray:groupie-viewbinding:2.8.1

i have added

repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}

but still gradle is unable to find it

bug waiting for owners

All 6 comments

Same problem.

Failed to resolve: com.xwray:groupie-viewbinding:2.8.1

333

Failed to resolve: com.xwray:groupie-viewbinding:2.8.1 @ValCanBuild

Same for 2.8.0

For those curious, I ended up with these helpers for now:

abstract class GroupieItem: Item<GroupieViewHolder>()

@Suppress("UNCHECKED_CAST")
class BindingViewHolder(private val viewBinding: ViewBinding) : GroupieViewHolder(viewBinding.root) {
    fun <T : ViewBinding> binding(): T = viewBinding as T
}

abstract class BindingItem : GroupieItem() {
    protected abstract fun initializeViewBinding(view: View): ViewBinding

    override fun createViewHolder(itemView: View): BindingViewHolder {
        val binding = initializeViewBinding(itemView)
        return BindingViewHolder(binding)
    }

    final override fun bind(viewHolder: GroupieViewHolder, position: Int) {
        bind(viewHolder as BindingViewHolder, position)
    }

    abstract fun bind(viewHolder: BindingViewHolder, position: Int)
}

class GroupieItemAdapter : GroupAdapter<GroupieViewHolder>()

fun GroupieItemAdapter.replaceItemsWith(
    recyclerView: RecyclerView,
    withAnimations: Boolean = false,
    block: MutableList<GroupieItem>.() -> Unit
): GroupieItemAdapter {
    if (withAnimations) {
        this.update(mutableListOf<GroupieItem>().apply(block))
    } else {
        val layoutManager = recyclerView.layoutManager

        val state = layoutManager?.onSaveInstanceState()

        this.clear()
        this.addAll(mutableListOf<GroupieItem>().apply(block))

        layoutManager?.onRestoreInstanceState(state) // fixme: Groupie should use adapter.notifyDataSetChanged() on replace instead of remove+insert -.-
    }
    return this
}

@Zhuinden better to go with https://github.com/lisawray/groupie/issues/333#issuecomment-607079271 imho

https://github.com/lisawray/groupie/issues/333 is now resolved and groupie-viewbinding is available on maven. Closing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattinger picture mattinger  路  3Comments

vahids28 picture vahids28  路  4Comments

dbof10 picture dbof10  路  5Comments

andhie picture andhie  路  3Comments

FabianTerhorst picture FabianTerhorst  路  6Comments