Home > Software design >  Is the automatic comparison in the Epoxy library based on DiffUtil?
Is the automatic comparison in the Epoxy library based on DiffUtil?

Time:10-10

I came across the Epoxy library while looking for information about RecyclerView.

Epoxy is a library that makes RecyclerView easier to use.

I haven't applied it to my app yet, but I think it will be easier if I apply it.

Because the RecyclerView I use is based on two view types, and both items are dynamically added/removed frequently (DiffUitl is also used).

However, while reading the description of the Epoxy library in Git,

I came across the following:

Additionally, Epoxy adds support for saving view state and automatic diffing of item changes.

I'm curious as to what automatic diffing you're talking about here works based on. Is it DiffUtil internally or simply notifyDatasetChanged()?

If it uses DiffUtil then I'm going to use Epoxy or I'll consider it.

CodePudding user response:

or simply notifyDatasetChanged()?

They are not using notifyDatasetChanged() as per the documentation:

Epoxy's automatic diffing to reduce the overhead, while also efficiently only updating the views that changed.


Is it DiffUtil internally

DiffUtil is used for the EpoxyController class, but not for EpoxyAdapter class, the documentation says:

The Android Support Library class DiffUtil is used for diffing in EpoxyController. For legacy reasons, the older EpoxyAdapter uses a custom solution for diffing.

So, As you still designing your app, I expect that you'll be using EpoxyController rather than the legacy EpoxyAdapter; and therefore, DiffUtil is already utilized.


If it uses DiffUtil then I'm going to use Epoxy or I'll consider it

It's up to you; using libraries in general has pros and cons in terms of continuity, security, limitations, complexity .. etc.

  • Related