Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Only set text size if the scale isn't 1 #3425

Closed
wants to merge 1 commit into from
Closed

Conversation

Hocuri
Copy link
Collaborator

@Hocuri Hocuri commented Nov 13, 2024

According to the Android Studio profiler, this is an easy win of 1.5ms when loading the chat activity.

I tested that when one or multiple of the latest message are large, and then I scroll up to text messages, these text messages are at scale 1. (because sometimes with the RecylcerView it happens that when you change something, it isn't reset to the default value when the item is recycled).

Copy link

To test the changes in this pull request, install this apk:
📦 app-preview.apk

@adbenitez
Copy link
Member

adbenitez commented Nov 13, 2024

I tested that when one or multiple of the latest message are large, and then I scroll up to text messages, these text messages are at scale 1. (because sometimes with the RecylcerView it happens that when you change something, it isn't reset to the default value when the item is recycled).

this is because in ConversationItem we always set/reset the font size (due to the custom font size setting we have in appearance which we contemplated removing recently:

bodyText.setTextSize(TypedValue.COMPLEX_UNIT_SP, Prefs.getMessageBodyTextSize(context));

I think the proper way to fix this is to check getTextSize() and compare with the target font size originalFontSize * scale and only call setTextSize() if they are different

@adbenitez
Copy link
Member

this PR becomes invalid with #3424

@adbenitez
Copy link
Member

#3424 got merged, text size is not set anymore outside in ConversationItem so it needs to be set inside AutoScaledEmojiTextView, so the issue of setting the size twice that this PR was targeting is solved! 🎉

@adbenitez adbenitez closed this Nov 15, 2024
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.

2 participants