Android Android Lists and Adapters Connecting the Data Wrapping Up

Sofya Kozhurinycheva
Sofya Kozhurinycheva
1,602 Points

Remove Recyclerview infinite scroll

https://teamtreehouse.com/library/android-lists-and-adapters-2 In the end, we got the app, where you can endlessly scroll through the data. Thus, if the weather forecast is given in the next 12 hours, after scrolling for 12 hours, we will see the forecast for the first hour, the second hour, ... How to fix it?

Jeremiah Shore
Jeremiah Shore
29,617 Points

I recommend checking where you are parsing the JSON data into the hourly forecast. Sounds like there might be a problem with your loop condition or with how you're retrieving the data JSONObject (where the hourly data is held as an array).

You may also want to double check the raw JSON data coming from DarkSky, and your expectations. When I was looking over your question, I noticed there was more data on my list than expected. Per their API documentation, "The hourly data block will contain data points starting at midnight (local time) of the day requested, and continuing until midnight (local time) of the following day." So, there should 49 hours returned. However, I don't recommend setting that as a static value, though it may sound tempting.

Try using the debugger within getHourlyForecast() and see what you can come up with. Be sure to let us know if you figure it out!