Code Monkey home page Code Monkey logo

ersiver / weatherchecker Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 3.0 18.06 MB

Android Weather app developed in Kotlin with use of Android Architecture Components, Coroutines, Retrofit, Moshi.

License: Apache License 2.0

Kotlin 100.00%
databinding-library databinding-android livedata coroutines retrofit2-coroutines workmanager-architecturecomponent widget location restful-api architecture-components mvvm-architecture workmanager coroutines-android

weatherchecker's Introduction

WeatherApp

Android Weather app developed in Kotlin. The app is composed of a single screen and the app widget.

WeatherFragment

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.

Widget

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).

Design

  • App offers a full edge-to-edge screen experience (draws behind the transparent navigation and status bars) and uses insets to move controls away from gesture area.
  • The app displays Snackbar explaining importance of the location permission with an action, that allows the user to navigate to the settings.
  • Scrolling list of forecasts is displayed in the RecyclerView widget.
  • Styled button behaves intuitively changing their appearance when they are pressed.
  • Spinner is displayed when the data is loaded.

Libraries and tools used:

  • Retrofit to make REST requests to the web service integrated with Coroutine to run operations in the background without creating multiple callbacks.
  • Moshi to handle the deserialization of the returned JSON to Kotlin data objects.
  • Android Architecture Components (ViewModel, LiveData, Data Binding, WorkManager).
  • The app accesses the set of supported location services through classes in the com.google.android.gms.location package.

Preview


Resources

  • Icons from Flaticon.com (byFreepik, Swifticons, Good Ware, Vitaliy Gorbachev, Those Icon, Hirschwolf Lineal, Iconixar, Eucalyp, Pixel Perfect).

OpenApi

  • using the OpenWeatherMapAPI for constructing RESTful.

License

License

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.

weatherchecker's People

Contributors

ersiver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.