智慧屏安装APP的最佳实践与跨平台小程序开发的结合
966
2022-10-22
使用MVVM模式实现的Android天气应用程序
Instant Weather ⛅
An Android weather APPlication implemented using the MVVM pattern, Retrofit2, LiveData, ViewModel, Coroutines, Room, Navigation Components, Data Binding and some other libraries from the Android Jetpack . Instant Weather fetches data from the OpenWeatherMap API to provide real time weather information. It also makes use of the Algolia Instant Search service which enables you search for weather conditions of various locations.
Architecture
The architecture of this application relies and complies with the following points below:
A single-activity architecture, using the Navigation Components to manage fragment operations.Pattern Model-View-ViewModel(MVVM) which facilitates a separation of development of the graphical user interface.Android architecture components which help to keep the application robust, testable, and maintainable.
Technologies used:
Retrofit a REST Client for Android which makes it relatively easy to retrieve and upload JSON (or other structured data) via a REST based webservice.ViewModel to store and manage UI-related data in a lifecycle conscious way.LiveData to handle data in a lifecycle-aware fashion.Navigation Component to handle all navigations and also passing of data between destinations.Timber - a logger with a small, extensible API which provides utility on top of Android's normal Log class.Algolia Search API - Android to quickly and seamlessly implement search within the application.Work Manager to manage Android background jobs.Material Design an adaptable system of guidelines, components, and tools that support the best practices of user interface design.Coroutines used to manage the local storage i.e. writing to and reading from the database. Coroutines help in managing background threads and reduces the need for callbacks.Data Binding to declaratively bind UI components in layouts to data sources.Room persistence library which provides an abstraction layer over SQLite to allow for more robust database access while harnessing the full power of SQLite.Paging Library helps you load and display small chunks of data at a time.Android KTX which helps to write more concise, idiomatic Kotlin code.Preferences to create interactive settings screens.
Installation
Instant Weather requires a minimum API level of 21. Clone the repository. You will need an API key from Open Weather to request data. If you don’t already have an account, you will need to create one in order to request an API Key. Also, you will need an API key, APP ID and an Index from Algolia to be able to implement the search functionality in the application. In your project's root directory, create a file apikey.properties and include the following lines:
API_KEY = "YOUR_API_KEY"ALGOLIA_API_KEY = "YOUR_API_KEY"ALGOLIA_APP_ID = "YOUR_APP_ID"
Contribution
All contributions are welcome. If you are interested in seeing a particular feature implemented in this app, please open a new issue so after which you can make a PR!
TODO
Incorporate a Dependency Injection framework
LICENSE
MIT LicenseCopyright (c) 2020 Mayokun AdeniyiPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~