Permalink
Browse files

Add android-architecture-components to Google Samples index (#225)

- Add packaging.yaml files with project metadata
- Ensure README.md files use correct format
  • Loading branch information...
tjohns authored and florina-muntenescu committed Oct 31, 2017
1 parent bf2a123 commit 6e0cd31d34782623add614703fa1abe4bb7bd575
@@ -0,0 +1,41 @@
#
# Copyright (C) 2017 The Android Open Source Project
#
# 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.
# GOOGLE SAMPLE PACKAGING DATA
#
# This file is used by Google as part of our samples packaging process.
# End users may safely ignore this file. It has no relevance to other systems.
---
# Values: {DRAFT | PUBLISHED | INTERNAL | DEPRECATED | SUPERCEDED}
status: PUBLISHED
# Optional, put additional explanation here for DEPRECATED or SUPERCEDED.
# statusNote:
# See http://go/sample-categories
technologies: [Android]
categories: [Architecture]
languages: [Java]
solutions: [Mobile]
# May be omitted if unpublished
github: googlesamples/android-architecture-components
# Values: BEGINNER | INTERMEDIATE | ADVANCED | EXPERT
level: ADVANCED
# Default: apache2. May be omitted for most samples.
# Alternatives: apache2-android (for AOSP)
license: apache2
@@ -1,23 +1,53 @@
# Room & RxJava Sample
Room & RxJava Sample
=====================
This is an API sample to showcase how to implement observable queries in [Room](https://developer.android.com/topic/libraries/architecture/room.html), with RxJava's [Flowable](http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html) objects.
This is an API sample to showcase how to implement observable queries in
[Room](https://developer.android.com/topic/libraries/architecture/room.html), with RxJava's
[Flowable](http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html) objects.
# Functionality
Introduction
-------------
### Functionality
The sample app shows an editable user name, stored in the database.
# Implementation
### Implementation
#### Data layer
## Data layer
The database is created using Room and has one entity: a `User`. Room generates the corresponding SQLite table at
runtime.
The database is created using Room and has one entity: a `User`. Room generates the corresponding SQLite table at runtime.
Queries are executed in the `UserDao` class. The user retrieval is done via an observable query implemented using a `Flowable`. Every time the user data is updated, the Flowable object will emit automatically, allowing to update the UI based on the latest data. The Flowable will emit only when the query result contains at least a row. When there is no data to match the query, the Flowable will not emit.
Queries are executed in the `UserDao` class. The user retrieval is done via an observable query implemented using a
`Flowable`. Every time the user data is updated, the Flowable object will emit automatically, allowing to update the UI
based on the latest data. The Flowable will emit only when the query result contains at least a row. When there is no
data to match the query, the Flowable will not emit.
## Presentation layer
#### Presentation layer
The app has a main Activity that displays the data.
The Activity works with a ViewModel to do the following:
* subscribe to the emissions of the user name and update the UI every time there is a new user name emitted
* notify the ViewModel when the "Update" button is pressed and pass the new user name.
The ViewModel works with the data source to get and save the data.
Room guarantees that the observable query will be triggered on a background thread. In the Activity, the Flowable events are set to be received on the main thread, so the UI can be updated. The insert query is synchronous so it's wrapped in a Completable and executed on a background thread. On completion, the Activity is notified on the main thread.
Room guarantees that the observable query will be triggered on a background thread. In the Activity, the Flowable events
are set to be received on the main thread, so the UI can be updated. The insert query is synchronous so it's wrapped in
a Completable and executed on a background thread. On completion, the Activity is notified on the main thread.
License
--------
Copyright (C) 2017 The Android Open Source Project
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.
@@ -0,0 +1,41 @@
#
# Copyright (C) 2017 The Android Open Source Project
#
# 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.
# GOOGLE SAMPLE PACKAGING DATA
#
# This file is used by Google as part of our samples packaging process.
# End users may safely ignore this file. It has no relevance to other systems.
---
# Values: {DRAFT | PUBLISHED | INTERNAL | DEPRECATED | SUPERCEDED}
status: PUBLISHED
# Optional, put additional explanation here for DEPRECATED or SUPERCEDED.
# statusNote:
# See http://go/sample-categories
technologies: [Android]
categories: [Architecture]
languages: [Kotlin]
solutions: [Mobile]
# May be omitted if unpublished
github: googlesamples/android-architecture-components
# Values: BEGINNER | INTERMEDIATE | ADVANCED | EXPERT
level: ADVANCED
# Default: apache2. May be omitted for most samples.
# Alternatives: apache2-android (for AOSP)
license: apache2
@@ -1,23 +1,52 @@
# Room & RxJava Kotlin Sample
Room & RxJava (Kotlin) Sample
============================
This is an API sample to showcase how to use [Room](https://developer.android.com/topic/libraries/architecture/room.html), with RxJava's [Flowable](http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html) objects in Kotlin.
This is an API sample to showcase how to use [Room](https://developer.android.com/topic/libraries/architecture/room.html),
with RxJava's [Flowable](http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html) objects in Kotlin.
# Functionality
Introduction
-------------
### Functionality
The sample app shows an editable user name, stored in the database.
# Implementation
### Implementation
#### Data layer
## Data layer
The database is created using Room and has one entity: a `User`. Room generates the corresponding SQLite table at
runtime.
The database is created using Room and has one entity: a `User`. Room generates the corresponding SQLite table at runtime.
Queries are executed in the `UserDao` class. The user retrieval is done via an observable query implemented using a `Flowable`. Every time the user data is updated, the Flowable object will emit automatically, allowing to update the UI based on the latest data. The Flowable will emit only when the query result contains at least a row. When there is no data to match the query, the Flowable will not emit.
Queries are executed in the `UserDao` class. The user retrieval is done via an observable query implemented using a
`Flowable`. Every time the user data is updated, the Flowable object will emit automatically, allowing to update the UI
based on the latest data. The Flowable will emit only when the query result contains at least a row. When there is no
data to match the query, the Flowable will not emit.
## Presentation layer
#### Presentation layer
The app has a main Activity that displays the data.
The Activity works with a ViewModel to do the following:
* subscribe to the emissions of the user name and updates the UI every time there is a new user name emitted
* notify the ViewModel when the pressed the "Update" and passes the new user name.
The ViewModel works with the data source to get and save the data.
Room guarantees that the observable query will be triggered on a background thread. In the Activity, the Flowable events are set to be received on the main thread, so the UI can be updated. The insert query is synchronous so it's wrapped in a Completable and executed on a background thread. On completion, the Activity is notified on the main thread.
Room guarantees that the observable query will be triggered on a background thread. In the Activity, the Flowable events
are set to be received on the main thread, so the UI can be updated. The insert query is synchronous so it's wrapped in
a Completable and executed on a background thread. On completion, the Activity is notified on the main thread.
License
--------
Copyright (C) 2017 The Android Open Source Project
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.
@@ -0,0 +1,41 @@
#
# Copyright (C) 2017 The Android Open Source Project
#
# 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.
# GOOGLE SAMPLE PACKAGING DATA
#
# This file is used by Google as part of our samples packaging process.
# End users may safely ignore this file. It has no relevance to other systems.
---
# Values: {DRAFT | PUBLISHED | INTERNAL | DEPRECATED | SUPERCEDED}
status: PUBLISHED
# Optional, put additional explanation here for DEPRECATED or SUPERCEDED.
# statusNote:
# See http://go/sample-categories
technologies: [Android]
categories: [Architecture]
languages: [Java]
solutions: [Mobile]
# May be omitted if unpublished
github: googlesamples/android-architecture-components
# Values: BEGINNER | INTERMEDIATE | ADVANCED | EXPERT
level: ADVANCED
# Default: apache2. May be omitted for most samples.
# Alternatives: apache2-android (for AOSP)
license: apache2
View
@@ -1,17 +1,20 @@
Android Architecture Components Basic Sample
===================================
=============================================
This sample showcases the following Architecture Components:
* [Room](https://developer.android.com/topic/libraries/architecture/room.html)
* [ViewModels](https://developer.android.com/reference/android/arch/lifecycle/ViewModel.html)
* [LiveData](https://developer.android.com/reference/android/arch/lifecycle/LiveData.html)
## Features
Introduction
-------------
### Features
This sample contains two screens: a list of products and a detail view, that shows product reviews.
### Presentation layer
#### Presentation layer
The presentation layer consists of the following components:
* A main activity that handles navigation.
@@ -46,7 +49,7 @@ The app uses a Model-View-ViewModel (MVVM) architecture for the presentation lay
});
```
### Data layer
#### Data layer
The database is created using Room and it has two entities: a `ProductEntity` and a `CommentEntity` that generate corresponding SQLite tables at runtime.
@@ -61,7 +64,7 @@ To access the data and execute queries, you use a [Data Access Object](https://d
Queries that return a `LiveData` object can be observed, so when a change in one of the affected tables is detected, `LiveData` delivers a notification of that change to the registered observers.
### Transformations
#### Transformations
Fragments don't observe the database directly, they only interact with ViewModel objects. A ViewModel observes database queries as well as the `DatabaseCreator`, which exposes whether the database is created or not.
@@ -93,8 +96,8 @@ The following diagram shows the general structure of the sample:
Exercise for the reader: try to apply a transformation to the list of products in the ViewModel
before they are delivered to the fragment. (hint: `Transformations.Map`).
## License
-------
License
--------
Copyright 2015 The Android Open Source Project, Inc.
@@ -0,0 +1,41 @@
#
# Copyright (C) 2017 The Android Open Source Project
#
# 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.
# GOOGLE SAMPLE PACKAGING DATA
#
# This file is used by Google as part of our samples packaging process.
# End users may safely ignore this file. It has no relevance to other systems.
---
# Values: {DRAFT | PUBLISHED | INTERNAL | DEPRECATED | SUPERCEDED}
status: PUBLISHED
# Optional, put additional explanation here for DEPRECATED or SUPERCEDED.
# statusNote:
# See http://go/sample-categories
technologies: [Android]
categories: [Architecture]
languages: [Java]
solutions: [Mobile]
# May be omitted if unpublished
github: googlesamples/android-architecture-components
# Values: BEGINNER | INTERMEDIATE | ADVANCED | EXPERT
level: ADVANCED
# Default: apache2. May be omitted for most samples.
# Alternatives: apache2-android (for AOSP)
license: apache2
Oops, something went wrong.

0 comments on commit 6e0cd31

Please sign in to comment.