Skip to content

graviton57/NewAndroidArchitecture

Repository files navigation

Android Architecture Components

What are Architecture Components?

Architecture Components is a new library by Google that has the aim to help us design application that are “robust, testable, and maintainable”. In a nutshell, this library helps us to better handle the persisting of data across lifecycle events and configuration changes, whilst also helping us to create a better architecture application and avoid bloated classes that are difficult to maintain and test.

The basic blocks

The basic blocks of the architecture components include the following:

  • Room – A SQLite object mapper. Very similar to other libraries such as ORMlite or greenDAO. It uses SQL while still allowing compile time guarantees on the queries.
  • LiveData – A Lifecycle aware observable core component.
  • ViewModel – The communication points with the rest of the application for Activities / Fragments. They are UI code free and outlive the activity or fragment.
  • Lifecycle – A core part of the Architecture components, it contains information about the lifecycle state of a component (for instance an Activity).
  • LifecycleOwner – Core interface for components that have a Lifecycle (Activities, Fragments, Process, your custom component).
  • LifecycleObserver – Specifies what should happen when certain Lifecycle methods are triggered. Creating a LifecycleObserver allows components to be self-contained

Sample

Here's a simple sample app using geonames API http://www.geonames.org and that demonstrates some parts of Android Architecture Components

Effect

Library reference resources

License

   Copyright 2017 Igor Gavrilyuk

   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.

Releases

No releases published

Packages

No packages published

Languages