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

Merge download adapters and performance improvements #1145

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

Luna712
Copy link
Contributor

@Luna712 Luna712 commented Jun 19, 2024

Fixes

  • The download icon bug is fixed
  • The bug where when scrolling the bytes sometimes use from the wrong item is fixed
  • Lag is improved — when you get to 20-30 items it still lags but it is still about 2x better then before this change with the same amount of downloads
  • Fixes extra unnecessary reload items that cause it to visually refresh items every time you open the downloads tab, or go back from a child entry
  • Fixes the issue of when a download is deleted it causes the byte size to disappear from the next item directly underneath the one that was deleted until you went out of downloads and back in
  • The go to child arrow icon actually displays now

Cleanup/Refactoring

  • Major cleanup and refractoring to DownloadFragment and DownloadChildFragment
  • Merge DownloadHeaderAdapter and DownloadChildAdapter into a single more modernized DownloadAdapter to create a more unified code base and making it easier in the future for common code handling for things planned in the future such as multi-delete handling
  • Use DiffUtil to more seamlessly add or remove items from the adapter by only adding, removing, or reloading the specific items we need to rather than reloading the entire adapter dataset

Performance Profiling

Both use the same downloads:

  • Before: took approximately 18 seconds to load the downloads tab for the first time
  • After: took approximately 9 seconds to load the downloads tab for the first time

NOTE: this could just be coincidence though

Luna712 added 19 commits June 8, 2024 13:56
This could honestly be a horrible way to impliment this (or maybe you don't want it at all) but figured I would give it a try as I often am used to you being able to on other apps so often out of habbit try like this and of course does not work.

This also seems to fix an issue where downloaded icon becomes mixed with in progress and downloaded overlapping on scroll if you have inprogress downloads as well as size becoming inaccurate while scrolling (it used the wrong file's size sometimes) which seems to be fixed with `setItemViewCacheSize`. `setHasFixedSize` also improves performance by reducing the need to continue re-requesting layout when it does not need to (testing did not show any issues with it anyway, but not sure if this is the best way to do either of these things.

Known issues:
* Does not work for series/individual episodes
* Delete icon UI needs improvements

TODO (for further download improvements; maybe in follow-ups):
* Show more information (IE synopsis/descriptions) for downloaded content
* Further performance improvements for UI threads etc...


If the entire concept of this idea is undesired I suppose we can close it and I will just do some of the other things to improve performance etc... (IE when having a moderate amount of downloads scroll is very laggy which this also seems to at least improve quite a lot.
You now have to click the delete icon. This was a UX choice so you don't inadvertently swipe and create unexpected popups
… and other cleanup


We can use adapter.notifyItemRemoved and remove it from the cardList in adapater directly since we do understand the position in this case. It works better because it does not require reloading everything and causes less bugs with the view model.

I am not sure if this was the proper way to do this. If not I can revert the change to this method

It also removes the need for a callback in DownloadButtonSetup
@Luna712 Luna712 changed the title Merge download adapters and minor performance improvements Merge download adapters and performance improvements Jun 20, 2024
@Luna712
Copy link
Contributor Author

Luna712 commented Jun 20, 2024

@fire-light42

I tested this now and it seems to work with pretty significant performance improvements. For one the updateList in view model was always refreshing data causing it to sometimes refresh multiple times on a single request which this also appears to correct (at least visually stops the items from refreshing unless they actually have updates to refresh) additionally the merginf of the adapters was just done as a step towards the multi download select because it allows more common code rather than a bunch of duplicate stuff to work around the difference in adapters. So it just makes future expansion a bit easiser.

If you don't want it done like this I can do it another way if you have better suggestions. Overall this should be ready for review though now.

@Luna712
Copy link
Contributor Author

Luna712 commented Jun 20, 2024

Okay so further testing, this actually seems to fix a lot more problems then I even intended.

  • The download icon bug is fixed
  • The bug where when scrolling the bytes sometimes use from the wrong item is fixed
  • Lag is improved — when you get to 20-30 items it still lags but it is still about 2x better then before this change with the same amount of downloads
  • It fixes extra unnecessary reload items that cause it to visually refresh items every time you open the downloads tab, or go back from a child entry
  • Fixes the issue of when a download is deleted it causes the byte size to disappear from the next item directly underneath the one that was deleted until you went out of downloads and back in — I am not to confident this is 100% fixed but it does appear to be significantly improved as it didn't reproduce like it used to 100% of the time

@Luna712
Copy link
Contributor Author

Luna712 commented Jun 21, 2024

Okay my new version should be done. I decided to go further with this PR and make things even better and more organized so it's easier to work on my next project: multi-delete downloads. Making the code cleaner and easier to manage helps make that a bit easier as well...

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