last day (16 days later) » 

10:38 PM
1
A: My Weather app gets response but doesn't display it

DroidAfter a discussion and also from my comments to the question the model mapping the JSON response was not correct and all that was required was to map the response correctly to the Java model.

 
After following your instructions, it has been able to display data on the app. I appreciate that a lot. Don't get angry, but I boldly emphasized my main aim: to search and display any city data typed on the edittext but as of now, it can only display any city I write on the q= in the ApiInterface i.e q=london. I need to enable it to display any city data as he did here stackoverflow.com/questions/65005292/…, then I'll tick this answer as correct
 
You need to remove "q=London&" from your ApiInterface.java class, refer to the answer you have linked
 
when i remove it, it crashes with this error: java.lang.NullPointerException: Attempt to invoke virtual method 'com.texra.preciseweatherforecast.Retrofit.Example$Main com.texra.preciseweatherforecast.Retrofit.Example.getMain()' on a null object reference. The problem is somewhere else
 
That is because in firstfragment.java you are calling getWeatherData and passing the contents of the search field on launch which is empty so the request has "q=" and you get an error. Also, you have the search button with a click listener in HomeActivity.java and that calls a different getWeatherData which only update the timeField as opposed to how you update fields in firstfragment.java using its getWeatherData()
 
Okay I understand, is there any solution to this?. I'd rather remove the timefield than not pass the data to the fragment because my fragment is my first bottom nav bar that displays the data and swipes on current tab
 
10:38 PM
That would out of scope of this particular question in my opinion. It would be knowledge of basic Android elements and Java. All that is required is to ensure that the search click listener calls getWeatherData() with the content of the text field and then in the following onResponse of the call the relevant UI fields are updated from the response object. Hope that helps.
 
To be honest, the only way I'll understand is if you can help me with the suggested code to use, please I'm really quite confused as how you explained it
 

  last day (16 days later) »