Android Weather app developed in Kotlin with use of Android Architecture Components, Coroutines, Retrofit, Moshi.
Android Weather app developed in Kotlin. The app is composed of a single screen and the app widget.
Displays current weather conditions and a 14-day forecast for the device’s location. It also allows to search the weather by a city name.
The app integrates coroutines with Retrofit to fetch weather information and binds all UI components in the XML layout to data sources using a DataBinding rather than programmatically. The UI calls are done in Binding Adapters reducing boilerplate code in the fragment. All is done following Model-View-ViewModel (MVVM) architecture for the presentation layer. Using repository the web services is abstracted from the rest of the app. The weather is exposed from the view model via LiveData and bound to a views so they’re refreshed automatically when condition changes. The button’s onClick attribute and the TextWatcher attached to the EditText are bound to the view model via a lambda expression.
Displays up to date weather info for the current device’s location. The widget is updated periodically with new data through a WorkManager. When the widget is added to the screen, the WorkManager schedules repeated background work to request location updates and fetch weather data from the API performing suspending work. When the widget is removed the background work is terminated. In addition to the FINE location permission, the app has support for Android 10 and 11 by adding logic to access location in the background (android.permission.ACCESS_BACKGROUND_LOCATION).
```
Copyright 2020 Ersiver
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.