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

Fast search for larger files #702

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ram-on
Copy link

@ram-on ram-on commented Nov 3, 2023

Issue

Searching for text using a text file that holds few kilobytes of data results in the app become unresponsive, extremely sluggish and very slow.

Cause

The issue is cause by the EditText.highlightText(). Whenever a user tries to search for a string, this function tries to finds all instances of the string and replace them with SpannableString. More specifically, EditText.setText() function is extremely slow when setting SpannableText: this function is called for every search instance found.

Solution

Instead of highlighting all search instances, the code now just highlights the first result and once the next button is clicked it will highlight the next result and so on.

Additionally EditText.setText() function appears to be faster then BackgroundColorSpan is used instead of SpannableText.

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.

None yet

1 participant