1. The issue
In last contribution for Hacktoberfest, I created a Weather Forecast App. However, users can watch the weather information of one city at a time that is a little inconvenient. I want to update the app so it will have a list of searched locations with some information in another page.
2. Modification process
Here are modifications I did to update the app:
-
Refactor source code by reconstructing the architecture
Putting all source code in themainclass is not a good practice so I decided to split the code into smaller models.

-
AppControllergets data from API and return theJSONobject to other models. -
Mainstarts the app, prepares views. -
Weather Datastores information of a weather data object -
City Adapterdescribes how to display each City's info toListView -
HistoryListAcitivitydisplays info and listens for event on eachListViewitem.
-
Add new
Listbutton to the main screen which links to theHistory List Activityand passes anArrayListof city's name to this activity.

View more details in PR
3. Throwback
During the modification process, the hardest part will be splitting the source code. I faced a problem with multi-thread in Java. The data was set to the view before it was returned from API. I tried to apply some knowledge about Thread learning from JAC444 but it did not work well.
As such, I started seeking help from an Android Dev Senior. He is very helpful and enthusiastic. After communicating with him, I found out the solution and got a lot of useful tips for working with Android App.
All in all, thank you so much for reading the post.
Happy coding!

Top comments (0)