apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

Make the Contributions activity load only a dozen elements, then load more if the user scrolls down

Open nicolas-raoul opened this issue 2 years ago • 9 comments

Currently the Contributions activity, just upon opening the app, shows like 5000 thumbnails (it might be 1000 or 10000 I didn't count nor check, if someone finds more info please comment).

It probably takes more memory than if we just loaded a dozen. I suspect it might be generating a lot of unnecessary network traffic to get thumbnails. Another problem is that once I have scrolled down the 5000, I can't scroll down more, even though I have 25000+ contributions so I should be able to scroll much more.

The task here would be to replace this behavior with a list that shows a dozen elements at first. If the user scrolls down, then the app would load more thumbnails.

https://github.com/user-attachments/assets/f315732b-9f21-4c9d-8968-454062b13fda

^ I know I have uploaded 20000+ pictures before that Venezia picture.

nicolas-raoul avatar Nov 13 '24 04:11 nicolas-raoul

Hello @nicolas-raoul, can you please assign me this issue. But there can be a delay of 2 weeks because of university exams. Incase, I get time during them I will try to complete this one :-)

kanahia1 avatar Nov 13 '24 18:11 kanahia1

No worries, it is not urgent at all. :-)

nicolas-raoul avatar Nov 13 '24 22:11 nicolas-raoul

Hi @nicolas-raoul, finally my exams are over. Starting work on it!

kanahia1 avatar Dec 03 '24 20:12 kanahia1

Hi @kanahia1! Any progress to share? Even if you don't have a solution yet, would you mind sharing what you found, what you checked/tried, maybe what did not work? I assume you still intend to work on this, but if not please let us know. :-)

github-actions[bot] avatar Nov 15 '26 15:11 github-actions[bot]

Hi @kanahia1, any progress to share on this? If you're not working on it anymore, no worries.

@nicolas-raoul if it's free, I'd like to take it. The list already loads in small batches (30 first, then 10 at a time), so I think the real problem is the "can't scroll down more" part.

The app remembers where it stopped in your uploads only in memory. After a restart, reaching the end of the saved list loads your newest 10 uploads again instead of the next older ones, so nothing new shows up. That's probably also why scrolling to the bottom showed new uploads in #5579.

Here's what I'd do, following Android's advice for this callback ("If you want to perfectly resume your query, even if the app is killed and resumed, you can store the key on disk"):

  1. After each older page is saved, store the API's continue value for that user.
  2. When you reach the end, continue from it, also after a restart.
  3. Pull to refresh still loads the newest uploads like now, without moving that position.

I tried it on main with tests for restart, pull to refresh, the last page and a failed load, and the related existing tests, ktlint and detekt pass. I haven't seen it on a device yet, that needs an account with a lot of uploads.

Can I work on this?

Medhansh-741 avatar Nov 24 '26 17:11 Medhansh-741

Thanks a lot for the detailed analysis, @Medhansh-741! This issue is currently assigned to @kanahia1, so I can't assign it to you just yet.

@kanahia1, are you still actively working on this? If not, no worries at all — just let us know so that the issue can be unassigned and handed over to @Medhansh-741. Thanks!

nicolas-raoul avatar Nov 24 '26 18:11 nicolas-raoul

Hi @kanahia1! Gentle ping, did you have time to look at this issue? If you are too busy, we might unassign it in 2 weeks so that someone else gets a chance to give it a try, thank you for your understanding. If you want to keep this issue, please comment here with the keyword #KEEP, thanks!

github-actions[bot] avatar Nov 29 '26 16:11 github-actions[bot]

Scrolling is still not ideal in main, I can't scroll further than a pic I uploade two weeks ago.

By the way, why can't we just use the normal way Android apps do this, probably a recycler view? It seems like a very normal use case.

nicolas-raoul avatar Nov 30 '26 09:11 nicolas-raoul

@nicolas-raoul opened #7474 for this.

About the recycler view: the list already is one, with Paging loading 10 at a time. The bug is that if loading older uploads fails once, Paging never asks again, and after a restart the app first re-downloads every page it already has, so with a lot of uploads one failure on the way stops it. The PR saves where it stopped and retries at the end of the list.

Medhansh-741 avatar Nov 30 '26 10:11 Medhansh-741