Closed AngleV closed 8 years ago
Hey @AngleV! I assume you are talking about the sample project. Is that correct?
@JVillella Yes that's right !!!
Ah ok, that's helpful. The sample project uses Picasso to load the drawables into the ImageViews while scrolling. It seems that this operation is the culprit and will require further investigation. We have specified a large enough in-memory cache for Picasso, but it doesn't change anything. If you use this outside the sample, and load in images some other way, it shouldn't be a problem. Nevertheless, I'll take a further look at this. Thank you!
I noticed that the sample is initially chopping, but it's fine after that. Digging a little deeper, it looks like some heavy work is being done in aspectRatioForIndex, namely line 26 of PhotosAdapter:
Drawable drawable = mContext.getResources().getDrawable(mImageResIds[index]);
I added some logs and it was taking anywhere between 70ms to 115ms. Removing that line causes the choppiness to go away (I just returned 1.0 as a test). Just wanted to save you the trouble of searching around!
Hey @a64adam! Appreciate it! I believe this is correct. This synchronous call to getDrawable(...)
is causing a slow down. Picasso is doing its work off the main thread. I've replaced the getDrawable(...)
with a BitmapFactory.decode(...)
and query strictly for the bounds. I also now precompute this data so it's not being continuously calculated. Thanks!
Have you test it ? On a Samsung Galaxy s6 with L android it does not work at all scroll is very choppy images are disappeared as you scroll back again. I can provide a screen capture if you wish