PhotoGalleryViewModel Not Passing List

The “items” variable is getting populated inside the init block but it list is not getting passed that. I’m receiving an empty “Response Received: ” in the logs.

Unless I’ve imported the wrong library everything is the same as yours. Is there a GitHub repository I could check? or was there an error in the book somewhere?

This is a strange error. I would expect that if something is wrong, your app would crash. Can you roll back some of your changes and share what you see in Logcat after you enter in the AndroidManifest.xml permission in Listing 20.11? And do the same thing after Listing 20.18?

The issue seems to be after Listing 20.28. I would think it’s to do with the StateFlow. What version of Kotlin is required? I’m running 211-1.6.21-release-334-AS7442.40

Interesting. Do you see anything in Logcat? Maybe an error is occurring and it would populate there. Also, what happens when you run the app after Listing 20.29? Does anything appear in Logcat then?

I’m using a different API(Running locally) Set up the same way as the Flickr API. Also, I’m using the names Home & Listing instead of photo. So you can see that the ViewModel is retrieving data from the API but the ViewModel is not passing the data to the Fragment.

You are never passing the data from the network into your StateFlow. Add this line after line #28 in your HomeGalleryViewModel:

_listingItems.value = items
1 Like

Oh wow :man_facepalming: I think I’ve been staring at the screen for way too long. Thank you, it’s working

1 Like