Question 1: When I load an image using the Coil library, I do it in the Fragment or Activity: imageView.load("https://example.com/image.jpg"). Is it OK to use the internet connection (method load()) from the UI? Doesn't it break the app architecture? Should I try to move load() into another class, ViewModel, or create a network package?
Question 2: What is the best practise: 1) To use ViewBinding and simply load an image with binding.imageView.load("https://..."), or 2) To use DataBinding and Binding Adapters to load an image?
I'm trying to go through the Google codelab "Load and display images from the Internet" The codelab is using DataBinding and Binding Adapters with Coil to manage images, and as for me, it's complicates the code a lot. Is it really the best practise to use Binding Adapters with Coil? Any opinions are welcome! Please share your experience!
I made a short video, where I tried to load and display images without Binding Adapters. While connecting to the internet is happening in the ViewModel inside the coroutine, the image is loading in the onBindViewHolder() method of the RecyclerView. It worked! However, I’m still confused what is the best practise. Here is the link to the video: How To Load Images From The Internet I hope it will help someone who has the same questions.