Commit 44f0b302 authored by Mark Murphy's avatar Mark Murphy
Browse files

more updates

parent 78b95f88
......@@ -8,17 +8,17 @@ samples:
`androidx.activity:activity` artifact, though in practice you will use it
mostly from `FragmentActivity`, `AppCompatActivity`, and similar classes.
`viewmodels()` is a property delegate, allowing you to use syntax like:
`viewModels()` is a property delegate, allowing you to use syntax like:
```
class MainActivity : AppCompatActivity() {
val viewmodel: MainViewModel by viewmodels()
val viewmodel: MainViewModel by viewModels()
}
```
Then, when you first access `viewmodel`, the delegate will look up the `ViewModel`
for you, so you can avoid the `ViewModelProviders.of()` statement and a
`lateinit var`, the way we normally get a `ViewModel`.
`lateinit var`, the way we used to get a `ViewModel`.
However, be careful: just because this is now encapuslated in a property
delegate does not change the timing rules. Do not attempt to reference
......
......@@ -15,6 +15,9 @@ docs:
title: 'Android Jetpack: Understand the CameraX Camera-Support Library'
description: Google I|O 2019 conference video
articles:
-
url: https://medium.com/androiddevelopers/whats-new-in-camerax-fb8568d6ddc
title: What’s new in CameraX (2020-02-24)
-
url: https://joebirch.co/2019/05/22/exploring-camerax-on-android-use-cases/
title: 'Exploring CameraX on Android: Use Cases (2019-05-22)'
......
......@@ -3,3 +3,11 @@ docs:
articles:
samples:
--- |
This artifact contains an `observe()` extension function for `LiveData`,
one that allows you to provide the `Observer` in the form of a simple lambda
expression or other function type.
See [the `lifecycle-livedata-core` artifact](/artifacts/lifecycle/lifecycle-livedata-core/index)
for more about `LiveData`.
\ No newline at end of file
---
docs:
-
url: https://developer.android.com/topic/libraries/architecture/livedata
title: LiveData Overview
articles:
-
url: https://androidwave.com/working-with-livedata/
title: Working With LiveData (2019-02-27)
-
url: https://proandroiddev.com/when-and-why-to-use-android-livedata-93d7dd949138
title: When and why to use Android LiveData (2018-04-30)
samples:
-
url: https://gitlab.com/commonsguy/cw-jetpack-kotlin/tree/v0.6/InLivingColor
title: InLivingColor (example of custom LiveData subclass)
-
url: https://gitlab.com/commonsguy/cw-jetpack-kotlin/tree/v0.6/DiceLight
title: DiceLight (example of tying coroutines into LiveData)
--- |
This artifact contains `LiveData`, `MutableLiveData`, and the `Observer`
interface used to observe `LiveData`.
`LiveData` is a lightweight data holder with a lifecycle-aware observer
system. Observers, when registered, are given the existing value in the
`LiveData` (if there is one), plus any updates to the value while the observer
remains registered. Since observers are (usually) tied to lifecycles, `LiveData`
can automatically remove observers when their associated lifecycles are destroyed.
This eliminates the need to manually unregister these observers.
The resulting API is reactive: observers respond to data updates as they occur.
And, since `LiveData` is designed for use by Android UIs, observers are notified
on the main application thread, even if the data was updated on a background thread.
However, `LiveData` is not nearly as powerful as is either RxJava or Kotlin's
coroutines (including `Flow`). A popular pattern is to use one of those other
reactive frameworks for much of the work, then use `LiveData` for the "last mile"
delivery of data to activities and fragments.
As with many pieces of the Jetpack, `LiveData` was available before the Jetpack
was defined. If you see references to `android.arch.lifecycle.LiveData`, that
is the older Architecture Components edition. `androidx.lifecycle.LiveData`
is the Jetpack/AndroidX edition and is the preferred choice for modern development.
......@@ -3,3 +3,8 @@ docs:
articles:
samples:
--- |
This artifact contains `map()` and `switchMap()` extension functions
for `LiveData` that "map" to their `Transformations` counterparts. This
just saves a bit of typing and the `Transformations` import statement but
otherwise adds no new functionality.
\ No newline at end of file
---
docs:
-
url: https://codelabs.developers.google.com/codelabs/kotlin-android-training-live-data-transformations/index.html
title: "Android Kotlin Fundamentals 05.4: LiveData transformations"
articles:
-
url: https://blog.oozou.com/livedata-to-the-next-level-with-mediatorlivedata-and-transformations-8eb2a307af22
title: LiveData to the next level with MediatorLiveData and Transformations (2018-12-07)
-
url: https://androidx.tech/artifacts/lifecycle/lifecycle-livedata-core/index
title: "Android LiveData Transformation With Example: Map And SwicthMap (2018-07-23)"
-
url: https://proandroiddev.com/mediatorlivedata-to-the-rescue-5d27645b9bc3
title: "MediatorLiveData to the Rescue (2018-07-14)"
samples:
--- |
This artifact, despite its name, does not contain `LiveData`. Instead, that
is in [the `lifecycle-livedata-core` artifact](/artifacts/lifecycle/lifecycle-livedata-core/index).
Instead, this artifact is the home of `MediatorLiveData` and `Transformations`.
These are useful for adapting one `LiveData` to another. In particular,
`Transformations` has `map()` and `switchMap()` static methods that work akin
to their RxJava counterparts, allowing you to convert ("map") `LiveData` of one type
to another type.
---
docs:
articles:
-
url: https://proandroiddev.com/android-processlifecycleowner-by-example-2f965061b9da
title: Android ProcessLifecycleOwner by example (2019-08-20)
-
url: https://proandroiddev.com/react-to-app-foreground-and-background-events-with-processlifecycleowner-96278e5816fa
title: React to foreground and background events with ProcessLifecycleOwner (2017-10-14)
samples:
--- |
This artifact contains `ProcessLifecycleOwner`. This is Google's official solution
for the age-old question, "how do I know when my app has moved to the background?"
In a nutshell, `ProcessLifecycleOwner` watches for activities coming and going,
and it considers your app to be "stopped" overall if you have no foreground
activities for at least 700ms. Since `ProcessLifecycleOwner` is a `LifecycleOwner`,
you can observe "lifecycle" events for your whole app using the same sorts
of low-level tools that you can use for observing activity and fragment
lifecycles.
Note that adding this artifact to your project will add a `ContentProvider`,
supplied by the artifact, to your manifest.
Also, as with lots of pieces of the Jetpack, `ProcessLifecycleOwner` pre-dates
AndroidX. You will see references to `android.arch.lifecycle.ProcessLifecycleOwner`,
which has been replaced by `androidx.lifecycle.ProcessLifecycleOwner`.
The primary API has not changed, though.
......@@ -3,3 +3,7 @@ docs:
articles:
samples:
--- |
This artifact adds a `toPublisher()` extension function to `LiveData`
and a corresponding `toLiveData()` extension function to `Publisher`. These
simply wrap the corresponding methods on [`LiveDataReactiveStreams`](/artifacts/lifecycle/lifecycle-reactivestreams/) for simpler
use from Kotlin.
---
docs:
articles:
-
url: https://www.bignerdranch.com/blog/livedatareactivestreams-where-rxjava-meets-livedata/
title: "LiveDataReactiveStreams: Where RxJava meets LiveData (2019-04-29)"
samples:
--- |
This artifact provides interoperability between `LiveData` and the [Reactive Streams](http://www.reactive-streams.org/)
set of APIs. In practice, though, developers usually use it to get between
`LiveData` and RxJava 2's classes, using Reactive Streams classes as an intemediary.
Specifically, this artifact contains the `LiveDataReactiveStreams` class
and its `toPublisher()` and `fromPublisher()` methods that map `LiveData`
to and from `Publisher`. RxJava's classes, like `Observable` and `Single`,
then offer `fromPublisher()` factory methods to wrap the `Publisher`
in a more conventional type. However, you are welcome to use `Publisher`
directly, if you so choose.
---
docs:
articles:
-
url: https://android.jlelse.eu/coroutine-in-android-working-with-lifecycle-fc9c1a31e5f3
title: "Coroutine in Android: Working with Lifecycle (2019-09-08)"
samples:
--- |
This artifact provides some Kotlin-specific extensions to core lifecycle
classes, including:
- `coroutineScope()` on `Lifecycle`
- `lifecycleScope` on `LifecycleOwner`
......@@ -3,3 +3,8 @@ docs:
articles:
samples:
--- |
This artifact provides some low-level plumbing for the lifecycle system,
such as `LifecycleRegistry` and `LifecycleRegistryOwner`. Usually, you will
get this artifact pulled in via transitive dependencies from some higher-level
`androidx.lifecycle` artifact, such as [`androidx.lifecycle:lifecycle-livedata`](/artifacts/lifecycle/lifecycle-livedata).
\ No newline at end of file
......@@ -3,3 +3,13 @@ docs:
articles:
samples:
--- |
This artifact provides `LifecycleService`, a `Service` implementation
that dispatches lifecycle events and is a `LifecycleOwner`. If you wish
to use `LiveData` from an ordinary `Service`, switching to `LifecycleService`
as a base class will let you designate your service as the `LifecycleOwner`
to use when registering `LiveData` observers.
On the other hand, since this is a class, not an interface, this will not
work for any services that require another base class, such as `JobIntentService`
or `TileService`.
\ No newline at end of file
---
docs:
articles:
-
url: https://android.jlelse.eu/coroutine-in-android-working-with-lifecycle-fc9c1a31e5f3
title: "Coroutine in Android: Working with Lifecycle (2019-08-09)"
-
title: How to use the new Android coroutine viewModelScope in Clean Architecture (2019-05-21)
url: https://medium.com/@cesarmcferreira/how-to-use-the-new-android-viewmodelscope-in-clean-architecture-2a33aac959ee
-
url: https://medium.com/androiddevelopers/easy-coroutines-in-android-viewmodelscope-25bffb605471
title: "Easy Coroutines in Android: viewModelScope (2019-03-19)"
samples:
-
url: https://gitlab.com/commonsguy/cw-jetpack-kotlin/tree/master/DiceLight
title: "*Elements of Android Jetpack* DiceLight Sample"
description: This sample diceware app demonstrates the use of viewModelScope
--- |
Primarily, this artifact offers `viewModelScope`, an extension property
of `ViewModel` that provides a `CoroutineScope` associated with that
`ViewModel`. When the `ViewModel` is cleared, any coroutines associated
with the `viewModelScope` will be canceled. This is very useful for
operations where you do not need the results if the user navigates
away from the current screen.
---
docs:
-
url: https://developer.android.com/topic/libraries/architecture/viewmodel-savedstate
title: Saved State module for ViewModel
articles:
-
url: https://android.jlelse.eu/saved-state-viewmodel-f25b638cb83
title: "Android: Saved State ViewModel (2019-10-24)"
samples:
--- |
This artifact offers `SavedStateHandle` and related classes, allowing
a `ViewModel` to participate in the saved instance state `Bundle`
associated with its activity or fragment. This allows you to keep state
management in one place, putting items into the `SavedStateHandle`
where relevant and practical, while keeping other objects simply in
the `ViewModel` itself.
Note that the version numbers for this artifact are not synchronized with
other `ViewModel`-related artifacts.
---
docs:
-
url: https://developer.android.com/topic/libraries/architecture/viewmodel
title: ViewModel Overview
articles:
-
url: https://heartbeat.fritz.ai/passing-data-between-fragments-on-android-using-viewmodel-d47fa6773f9c
title: Passing Data Between Fragments on Android Using ViewModel (2019-07-30)
-
url: https://medium.com/mindorks/using-view-model-with-roomdatabase-95b790a9a66c
title: Using ViewModel with RoomDatabase (2019-03-15)
samples:
-
url: https://gitlab.com/commonsguy/cw-jetpack-java/tree/master/ViewModel
title: "*Elements of Jetpack* Basic ViewModel Example (Java)"
-
url: https://gitlab.com/commonsguy/cw-jetpack-kotlin/tree/master/ViewModel
title: "*Elements of Jetpack* Basic ViewModel Example (Kotlin)"
--- |
As the name suggests, this artifact contains `ViewModel`, the Jetpack solution
for retaining data across configuration changes. Despite its name, `ViewModel`
is not strictly tied to MVVM or other GUI architectures that use
"viewmodel" as a term.
This artifact also contains `ViewModelProvider` and `ViewModelStore`, ways for you
to obtain `ViewModel` instances. It also contains `AndroidViewModel`,
a `ViewModel` that has a `Context` that you can use for all those places
where you need a `Context`.
As with many facet of the Jetpack, `ViewModel` was introduced before the
migration to `androidx` Java packages. If you see references to
`android.arch.lifecycle.ViewModel`, the AndroidX equivalent has a near-identical
API and fills the same role.
......@@ -3,3 +3,13 @@ docs:
articles:
samples:
--- |
This library contains a backport of the deprecated framework implementation
of the `Loader` framework. Added back in API Level 11, loaders were envisioned
as a general-purpose solution for lifecycle-aware data loading for activities
and fragments. As it turned out, [`Loader` had design issues](https://commonsware.com/blog/2014/03/31/cwac-loaderex-failed-abstractions.html).
And the overall approaches for asynchronous data loading have changed
in the intervening years (RxJava, coroutines, `LiveData`, etc.).
As a result, this library exists mostly to support developers who invested
in `Loader` and need to keep using it despite the deprecation of the
framework implementation.
\ No newline at end of file
......@@ -3,3 +3,8 @@ docs:
articles:
samples:
--- |
This library contains `LocalBroadcastManager`, an in-process message bus with
an API designed after system broadcasts.
This library is officially deprecated.
\ No newline at end of file
......@@ -3,3 +3,7 @@ docs:
articles:
samples:
--- |
This library contains `VideoView2`, a replacement for the framework's `VideoView`.
`VideoView2` offers greater flexibility and better integration with modern
features like `MediaSession`, `AudioManager`, etc.
\ No newline at end of file
......@@ -3,3 +3,10 @@ docs:
articles:
samples:
--- |
This artifact contains a bunch of media-related classes, including:
- the AndroidX media-capable edition of `NotificationCompat`
- `MediaSessionManager`
- `AudioAttributesCompat`
- `AudioManagerCompat`
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment