Skip to content

Conversation

avmiyy
Copy link

@avmiyy avmiyy commented Feb 7, 2025

Why notifyDataSetChanged() is Suboptimal

Full Redraw: Calling notifyDataSetChanged() triggers a complete redraw of the entire RecyclerView, even if only a single item has changed.
Resource Intensive: This demands significant computational resources, particularly for large lists, as all items must be re-bound and re-drawn.
Undesirable Animations: A full redraw resets any animations associated with list items, leading to a visually jarring user experience.

Why DiffUtil is More Optimal

Precise Updates: DiffUtil calculates the minimal set of changes (additions, removals, changes, moves) required to transform the old list into the new list.
Targeted Operations: Based on these changes, the adapter uses notifyItemInserted(), notifyItemRemoved(), notifyItemChanged(), and notifyItemMoved() to update only the items that actually need updating.
Improved Performance: This significantly reduces the load on the system, resulting in a smoother and more responsive UI, especially with large lists or frequent data updates.
Preservation of Animations: DiffUtil preserves RecyclerView item animations, providing a more polished visual experience.
In summary, DiffUtil provides granular control over RecyclerView updates, minimizing the amount of work needed to refresh displayed data, in contrast to the all-or-nothing approach of notifyDataSetChanged().

@avmiyy
Copy link
Author

avmiyy commented Apr 18, 2025

@Arash63Dehghan
@DrKLO
@Bubu
@alabiaga
Hi, will it be merged?

@yashikada
Copy link

will it be merged?

I think no, is more important make changes to emoi or similar feature, maybe some colors.

@avmiyy
Copy link
Author

avmiyy commented Jun 27, 2025

I think no, is more important make changes to emoi or similar feature, maybe some colors.

It's not a feature, notifyDataSetChanged calls redrawing more often than necessary and i wanna fix it

@yashikada
Copy link

Oh yeah, I can understand you.
I was being ironic, unfortunately lately tg only thinks about the graphic aspect and not the rest.
For example they updated boringssl only recently from over 2 years ago.
They still compile with ndk 21 when now there is version 28 that maybe improves the performance.

@yashikada
Copy link

I tested your PR and don't work very well, these import are useless:

import androidx.annotation.Nullable;
import org.jetbrains.annotations.NotNull;

if I switch account the blue flag is not updated, so I see the previous account as selected and not the current.
I don't approve this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants