Redgram / redgram-for-reddit

An Open-Sourced Android Reddit Client
GNU General Public License v3.0
102 stars 19 forks source link

LinksView - App becomes unresponsive when loading big images in the preview of a post #44

Open sleepyfran opened 7 years ago

sleepyfran commented 7 years ago

Happens right after loading images like the one in this post. It continues unresponsive and laggy even if you scroll down or lose the preview out of sight, the only way to resolve the issue is to restart the app.

mhdatie commented 7 years ago

20

mhdatie commented 7 years ago

https://github.com/Redgram/redgram-for-reddit/blob/master/Redgram/app/src/main/java/com/matie/redgram/ui/common/views/widgets/postlist/dynamic/PostItemImageView.java#L65

setImageRequest should be setLowResImageRequest

https://github.com/Redgram/redgram-for-reddit/blob/master/Redgram/app/src/main/java/com/matie/redgram/data/managers/media/video/ImageManager.java#L89

In here I'm not even requesting the thumbnail anywhere.

sleepyfran commented 7 years ago

@MohamadAtieh I'm taking a look at it right now. At the moment of loading the image in the PostItemImageView should I use setThumbnail with the URL (getUrl()) or the thumbnail of the image (getThumbnail())? I tried both and with the original URL it looks much better but it consumes more data (as expected).

Maybe we can even move this to an option in the settings to allow the user to specify whether they want to limit the data usage?

mhdatie commented 7 years ago

Yes, we can do that but we need to understand the definition of low and high quality images. Once we do that, we need to explore ways to turn that media viewer into a separate component that can resolve a given request (url), check the cache, then request the real thing. If we are loading a low res image at first and then they click on the image to view a better one, there should be a mechanism to check the cache request the image.

So I would say:

  1. Determine what's available to show
  2. Design a component that deals with any kind of media efficiently
  3. Embed settings into that component as parameters.

The last point is important. The media component should be unaware of the preferences we store and recognize them as parameters that are set upon calling that component based on the state of the user.

What do you think?

mhdatie commented 7 years ago

https://www.reddit.com/hot.json?compact=true.json

This is an example of a listing that is returned from the API.