-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixes #5743 Reduce delay between peer reviews #5897
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I start testing now. :-)
@@ -100,10 +114,10 @@ protected void onCreate(Bundle savedInstanceState) { | |||
d[2].setColorFilter(getApplicationContext().getResources().getColor(R.color.button_blue), PorterDuff.Mode.SRC_IN); | |||
|
|||
if (savedInstanceState != null && savedInstanceState.getParcelable(SAVED_MEDIA) != null) { | |||
updateImage(savedInstanceState.getParcelable(SAVED_MEDIA)); // Use existing media if we have one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way to improve these comments rather than just remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I have added java doc to explain why I changed this part, but my teammates pushed a old version, sorry about that. the new version included java doc and kdoc for all changed part.
I tested today, unfortunately another bug in the app is making it sluggish so it was hard to compare. |
I just tested review in the main branch. Maybe I am too tired but I was not really able to notice the differences. Would you mind testing and telling us, for both this branch and the main branch: How many seconds does it take to perform 50 reviews (tapping Thanks a lot! :-) |
@u7805486 Just wanted to check in to know if you would be able to continue working on this PR 🙂 |
Description (required)
Fixes #5743
To solve this problem, I implemented a complete cache system. This system mainly includes the following key parts:
Media file cache mechanism
Added a fixed size (50 items) cache list to store media files
Used SharedPreferences to track cache time
Set a 24-hour cache expiration time
Batch check mechanism
No longer check the usage of each file separately
Implemented batchCheckFilesUsage method to check the usage of multiple files at once
Smart cache management (fetchAndCacheMedia())
Use RxJava's Observable.range to obtain multiple media files in parallel
Implemented cache time management to avoid using expired data
Error handling optimization (handleError())
Added a unified error handling mechanism。
Hide the loading indicator in time when an error occurs
Show friendly error prompts to users through Snackbar
Add processNextCachedMedia() for cache processing and isCacheExpired() for cache expiration check.
Modified the logic of checkWhetherFileIsUsedInWikis() and runRandomizer(). Introduced a cache mechanism to avoid repeated requests. Decided whether to use the cache or get new data based on the cache status. Reused cached data to avoid re-acquisition.
Tests performed (required)
Tested build on Pixel with API 35
When entering peer review mode, the cache will be automatically downloaded, with the quantity set by CACHE_SIZE. Currently, the quantity is 5. Every 5 skips will trigger a cache refresh, which takes 10-15 seconds, while subsequent skips load much faster.
Need help? See https://support.google.com/android/answer/9075928
Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request.