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 themain
class is not a good practice so I decided to split the code into smaller models.
-
AppController
gets data from API and return theJSON
object to other models. -
Main
starts the app, prepares views. -
Weather Data
stores information of a weather data object -
City Adapter
describes how to display each City’s info toListView
-
HistoryListAcitivity
displays info and listens for event on eachListView
item.
-
-
Add new
List
button to the main screen which links to theHistory List Activity
and passes anArrayList
of city’s name to this activity. -
Design view for
History List
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!
暂无评论内容