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

Fixes #5743 Reduce delay between peer reviews #5897

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

u7805486
Copy link

Description (required)

Fixes #5743

To solve this problem, I implemented a complete cache system. This system mainly includes the following key parts:

  1. 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

  2. Batch check mechanism
    No longer check the usage of each file separately
    Implemented batchCheckFilesUsage method to check the usage of multiple files at once

  3. 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

  4. 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.

Copy link
Member

@nicolas-raoul nicolas-raoul left a 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. :-)

app/.idea/gradle.xml Outdated Show resolved Hide resolved
@@ -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
Copy link
Member

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?

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.

@nicolas-raoul
Copy link
Member

I tested today, unfortunately another bug in the app is making it sluggish so it was hard to compare.
I will see if that bug can be fixed soon so that I can come back to this one soon enough.
Thanks for your patience!

@nicolas-raoul
Copy link
Member

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 Skip this image immediately each time)?

Thanks a lot! :-)

@sivaraam
Copy link
Member

sivaraam commented Dec 1, 2024

@u7805486 Just wanted to check in to know if you would be able to continue working on 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.

Reduce delay between peer reviews
4 participants