|
1 | 1 | ## Android Weather App |
2 | 2 |
|
| 3 | +This is a simple android weather application that fetches weather data from [WeatherApi](https://weatherapi.com). It provides current hour data, hourly weather forecast, seven days weather forecast and city search. Selected city from city search result is saved in a shared preference |
| 4 | +to use the location as default weather location. By default city **London, UK** is selected. |
| 5 | + |
3 | 6 | ### Features |
4 | 7 |
|
| 8 | +1. current weather report |
| 9 | +2. hourly weather forecast |
| 10 | +3. find and set weather location |
| 11 | +4. 7 days weather forecast |
| 12 | + |
5 | 13 | ### Learning Outcome |
6 | 14 |
|
7 | 15 | - **Storing Secret Information:** For api calls we need api key. But this key should not be pushed to public repositories. Therefore, the right way to store and pass the apikey or any sensitive data during build time is adding it in `local.properties` in project root. |
@@ -43,8 +51,17 @@ Like for this project gson converter is used so all the request body will be ser |
43 | 51 | path will be considered relative the domain part. So don't prepend `/` in service method url paths. For example: if `@GET("/current.json")` then requests to https://api.weatherapi.com/current.json not to https://api.weatherapi.com/v1/current.json . |
44 | 52 | - **OkHttpClient Interceptor:** In cases when I need to something for each request, then we can use OkHttpClient `Interceptor` interface to manipulate each request before sending. For example: this is project we need to append a `key` query which |
45 | 53 | contains the api key value. I added an Interceptor that appends `key` query parameter to each request. |
| 54 | +- **Get ViewModel:** using `ViewModelProvider.get(Class)` I can get and existing view model instance or create if not exists |
| 55 | +- **RecyclerView item click:** to handle recyclerview item click i have used `RecyclerView.OnItemTouchListener` and `GestureDetector`. GestureDetector requires a `OnGestureListener`. This gesture listener provides different methods to handle different |
| 56 | +click events like single click, long click etc. finally an instance of OnItemTouchListener to be added to RecyclerView with `addOnItemTouchListener` |
46 | 57 |
|
47 | 58 | ### Change Log |
| 59 | +- **v2.0** |
| 60 | + 4 features implemented |
| 61 | + 1. city search and change current weather location |
| 62 | + 2. detailed weather report for current hour |
| 63 | + 3. hourly weather forecast for current date |
| 64 | + 4. 7 days weather forecast for the current weather location |
48 | 65 |
|
49 | 66 | - **v1.0** |
50 | 67 | simple api call and display the current weather report for city **London** on success or log error body if request fails. |
|
0 commit comments