Coder Social home page Coder Social logo

forecast-bird's Introduction

forecast-bird

A sample app that shows weather forecast for Amsterdam

fetching done

Features

The app covers all the original requirements with an addition that it has a capability to cache the previously fetched forecast. That means, when we first open it, it will fetch a list of forecast if there is Internet connection. But the next time we open in a scenario of no Internet connection, the app will show the forecast list that it fetched in the first place instead of just showing an empty page.

Project structure

There are two flavors: mock and production. The mock flavor was born to serve writing Espresso tests. So in order to see how the app works in reality, we have to switch Build Variants on Android Studio to productionDebug.

App package is structured by features.

  • api: Defines all the data models that represent forecast data returned by the Yahoo server. Thus, also defines some networking classes interacting with the server.
  • data: Defines a SQLite-based storage for all the data models defined the api package.
  • forecast: Represents the Forecast screen.
  • util: Some utility classes used in various parts of the project.
  • binding: Provides additional BindingAdapters and BindingConversions.

Note that the project requires JDK8 to get it compiled successfully because it takes advantage of retrolambda to simplify some RxJava callbacks.

Architecture overview

Development of the app was driven by MVVM architecture to maximize capability of producing testable code. That's basically done by pulling lots of business logic code into the ViewModel layer.

The data binding library was utilized to wire relationship between the ViewModel side and the View side. For instance, ForecastViewModel expose a forecastItemViewModels property. That property is bound to a RecyclerView via a binding expression items="@{viewModel.forecastItemViewModels}". Right after ForecastRepository manages to fetch forecast, ForecastLoader is notified then and the loader will load data from database and update the forecastItemViewModels property accordingly. The RecyclerView will show that forecast list without us doing anything.

Testing

Run ./gradlew clean test connectedAndroidTest --continue to execute both unit and instrumentation tests. The instrumentation tests are located in the androidTestMock folder while the unit tests are inside the test folder.

TODO

  • Show more weather info rather than just forecast.
  • Support multiple cities.

License

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.

forecast-bird's People

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.