1

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.

ybybyb
  • 1,385
  • 1
  • 12
  • 33

1 Answers1

2

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.

Zain
  • 37,492
  • 7
  • 60
  • 84
  • thank you. `EpoxyAdapter` is legacy and deprecated right? Is it replaced by an `EpoxyController`? And if I use `DiffUtil` in Epoxy, I don't even need to override `equals()` or `hashCode()` for `DiffUtil` at all? – ybybyb Oct 09 '21 at 18:20
  • 1
    @ybybyb Yes, it's replaced by `ExpoxyController` .. You can check the [main components of expoxy here](https://github.com/airbnb/epoxy#basic-usage) .. [This is a recent tutorial](https://proandroiddev.com/epoxy-build-declarative-reusable-ui-components-3d10d2b09cb6) as well.. For the `equals() or hashCode()` part I am not sure.. but I think they implement them automatically, as you build the models within the ExpoxyController.. Let me check if I can find something – Zain Oct 09 '21 at 18:36
  • great. I'm sorry, but I have one more question. I'm a beginner and it's my first time using a library that replaces something. So I'm not sure if the use of the library is appropriate. Does the last word in your answer mean that using a library can be good or bad? – ybybyb Oct 09 '21 at 19:15
  • 1
    @ybybyb Using libraries is good that it facilitates some functionality for your with just a couple of line of codes; whereas if you write it yourself, it can take up hundreds of line of codes or something, so it saves time for you; but you may encounter a bug in the library that can't fix (for instance your app can be crashed at some client because of some bug of the library, so you have to wait until they update it... What if the library is discontinued (i.e. no more updates), then you have to change the entire solution to something else, this would make you lose clients – Zain Oct 09 '21 at 19:50
  • 1
    But in general, you can rely on libraries from big provides that continues to fix bugs, and update their dependencies to recent android releases, expoxy is one of them I guess.. I see they just updated it 12 days ago. – Zain Oct 09 '21 at 19:52
  • 1
    Thank you very much for the very detailed reply. It helped a lot. I decided to try the library for the first time. Of course, I don't know if it will work out as intended, but thanks anyway :) – ybybyb Oct 09 '21 at 20:18
  • 1
    @ybybyb Just came across a library that caused runtime issues to clients; hopefully it will be a chance for you to know one aspect of downside of libraries.. [Check out the comments](https://stackoverflow.com/questions/69476396/initloader-must-be-called-on-the-main-thread-doinbackground?noredirect=1#comment122864516_69476396) – Zain Oct 10 '21 at 07:08