Groupie: How not recycle all/some items ?

Created on 6 Nov 2019  路  8Comments  路  Source: lisawray/groupie

Hi all.
I have item list with "webView" inside. When I scroll list, "webView" over and over again loading content.

How properly disable recycle items ?

Overriding this method in item not work for me:

override fun isRecyclable(): Boolean {
    return false
}

Thanks)

question

Most helpful comment

@zabochen
You can simply override createViewHolder and call setIsRecyclable with false argument on created ViewHolder:

override fun createViewHolder(itemView: View): ViewHolder {
    return super.createViewHolder(itemView).apply {
        setIsRecyclable(false)
    }
}

All 8 comments

Hmm, this is interesting. Looking at the source code, we never actually call RecyclerView.ViewHolder.setIsRecyclable.

The only place where Item.isRecyclable() is used is in this one place in GroupAdapter:

    @Override
    public boolean onFailedToRecycleView(@NonNull VH holder) {
        Item contentItem = holder.getItem();
        return contentItem.isRecyclable();
    }

which I don't believe is sufficient. Maybe @lisawray can pitch in here?

@zabochen
You can simply override createViewHolder and call setIsRecyclable with false argument on created ViewHolder:

override fun createViewHolder(itemView: View): ViewHolder {
    return super.createViewHolder(itemView).apply {
        setIsRecyclable(false)
    }
}

@zabochen did @Kamil-H 's solution work for you? I tried @Kamil-H 's solution but the "webView" keeps loading content again and again when I scroll the list.

I needed a fast fix and I didn't check this solution.
I "disable" recyclerView, like this:

<androidx.core.widget.NestedScrollView>
<LinearLayout>
...
<androidx.recyclerview.widget.RecyclerView/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

Thanks @zabochen

Feels like you shouldn't be using Groupie for your use-case.

override fun createViewHolder(itemView: View): ViewHolder {
return super.createViewHolder(itemView).apply {
setIsRecyclable(false)
}
}
This code is not working for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nimrodda picture Nimrodda  路  3Comments

kawaiiDango picture kawaiiDango  路  5Comments

rpedretti picture rpedretti  路  3Comments

hardysim picture hardysim  路  3Comments

andhie picture andhie  路  3Comments