Answer the question
In order to leave comments, you need to log in
How do you solve the problem of loading resources that take more than 1 second to load?
I would like to know your opinion, your experience, how do you solve the problem of loading resources that take more than 1 second to load?
Suppose there is a method in which there is a download, for example, of an image. Timed download more than 1 sec. Immediately after the download code is another code (in the same method), following the example given, this is assigning this image to the container.
In a normal situation, it will happen like this: the method is being executed, the process of downloading the image begins, while the download process is in progress, the code execution moves on and the image is assigned to the container, but since the image did not have time to load, we get null.
How to make it so that the full download goes first, and only then the assignment to the container?
Maybe you're using Callbacks, maybe you're using streams, maybe you're passing an argument, maybe you're doing some extra checks.
Any opinion and experience will be interesting, especially with your example.
Answer the question
In order to leave comments, you need to log in
In your case, namely loading an image and displaying it in an ImageView, I advise you (however, like google https://developer.android.com/topic/performance/gr... ) to use popular libraries designed for this purpose, for example:
Picasso square.github.io/picasso
Glide https://github.com/bumptech/glide
Fresco https://github.com/facebook/fresco
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question