-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Some preloading questions #1607
Comments
What I suggest is to use a placeholder, or some placeholders. Placeholder(s) satisfy the "at least they will be visible during fast scrolling" requirement pretty well and they're not as resource intensive as separate thumbnails. If you want to go full-on with your behavior, you can achieve it by the following steps:
Size and transformation need to be the same for memory cache to hit! The |
Hi, thanks for the reply. I now copied the ListPreloader class and managed to solve issue #1 even though I'm not 100% happy with my code. I set lastFirstVisible=-1 in the constructor. This means that during the first call to onScroll() the preload always happens. But I also have to check if the preload was successful (i.e. if the dimensions have already been set) and otherwise I don't update lastFirstVisible. It still feels kind of hackish but it works. About #2: I'll take your advice and first try to use a placeholder. Since I only use local images that should already be cached in a resized version on disk, I wouldn't care so much about many requests, though. I might also try how this works at some point. Thanks for pointing me in the right direction. Tobias |
Ah, yes, the size is not known in the beginning. It's tricky sometimes, but if you can encapsulate it nicely, there may be no better solution. Tip: on GitHub never use |
Hi,
first of all many thanks for your great work with this library.
I use Glide 3.7.0 in a hobby project to display album art in a music player app. I managed to add on-scroll preloading with the ListPreloader class that you provide and this works very well. However I still have some issues / questions:
It seems that preloading only gets triggered once you really start scrolling. This means that if I start scrolling, the first items to become visible are not preloaded which is noticeable. I think this is because you use
if (firstVisible > lastFirstVisible)
in the onScroll callback instead of >=. Now I wonder if there's any way to work around this that I have overlooked. How can I have the first couple of invisible items preloaded when my GridView first becomes visible and the user hasn't scrolled yet?
If I scroll quite fast, the preloader doesn't catch up anymore at some point which is not surprising. Now I'd wish for the following behavior:
Is a behavior like this possible to emulate using your library?
Thanks,
Tobias
The text was updated successfully, but these errors were encountered: