Fixed: Improve article search in our application. #3849
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3848
Now we are using the same
ZimFileReader
object to search the articles. It reduces the search timing and avoids unnecessary allocation of objects in memory.Refactored the
SearchViewModelTest
for this change.After this change, a few codes are become unused so we have removed that from our application.
Fixed the test cases that were failing if
testPauseAndResumeInOtherLanguage
failed due to any reason. Because the language remains changed and other test cases will fail. Like it was failed in this PR on API level 30(/~https://github.com/kiwix/kiwix-android/actions/runs/9113243814/job/25054265367).Also, improved our
DownloadTest
, because after changing the language of the application online content will change according to the new language so now we are using a generic approach for downloading the zim file.Fixed the crash that playStore reported. It was due to the
render
method was called multiple times (7-14 times) when an item in the search list is clicked, which leads to unnecessary data loading and also causes a crash. The issue arises because the searchViewModel takes a moment to detach from the window, and during this time, this method is called multiple times due to the rendering process. To avoid unnecessary data loading and prevent crashes, we check if the search screen is visible to the user before proceeding. If the screen is not visible, we skip the data loading process. Below are crash logs reported by the playStore, and the same crash logs are generated by my device.