Status Update
Comments
il...@google.com <il...@google.com>
tr...@gmail.com <tr...@gmail.com> #2
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
a....@gmail.com <a....@gmail.com> #3
sj...@gmail.com <sj...@gmail.com> #4
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically (
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
sj...@gmail.com <sj...@gmail.com> #5
As a workaround I created this function utilizing produceState()
:
@Composable
fun currentLifecycleState(): State<Lifecycle.State> {
val lifecycleOwner = LocalLifecycleOwner.current
return produceState(
initialValue = Lifecycle.State.INITIALIZED,
) {
val observer = object : DefaultLifecycleObserver {
override fun onCreate(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onStart(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onResume(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onPause(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onStop(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
override fun onDestroy(owner: LifecycleOwner) {
value = owner.lifecycle.currentState
}
}
lifecycleOwner.lifecycle.addObserver(observer)
awaitDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
}
}
sa...@google.com <sa...@google.com>
ap...@google.com <ap...@google.com> #6
Branch: androidx-main
commit c1f4d85af7a690c310fc9dd60e27654ba2f4896e
Author: sanura <sanura@google.com>
Date: Tue Mar 07 01:16:59 2023
Add Lifecycle extension for composable collectAsState()
Adding a Lifecycle composable extension for developers
wanting to directly expose Lifecycle.State as a Compose State.
RelNote: "`Lifecycle.collectAsState()` extension added to
directly expose `Lifecycle.State` as Compose `State`. This
is equivalent (and a shorter alternative) to
`lifecycle.currentStateFlow.collectAsState()`."
Bug: 235529345
Test: lifecycleCollectAsState()
Change-Id: I1101507a270980554046f7505b356c9c923ad48e
M lifecycle/lifecycle-runtime-compose/api/current.txt
M lifecycle/lifecycle-runtime-compose/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-runtime-compose/api/restricted_current.txt
A lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleExtTest.kt
A lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleExt.kt
lm...@gmail.com <lm...@gmail.com> #7
lm...@gmail.com <lm...@gmail.com> #8
lm...@gmail.com <lm...@gmail.com> #9
ap...@google.com <ap...@google.com> #10
Branch: androidx-main
commit e9afa3a28b32897fef6717fea079c6296f3a2e5a
Author: sanura <sanura@google.com>
Date: Tue Apr 25 01:07:17 2023
Create LifecycleEventEffect composable
Adding LifecycleEventEffect composable API to
be used when running SideEffects based on a
particular Lifecycle.Event.
RelNote: "`LifecycleEventEffect` API has been
added to run side effects based on `Lifecycle.Event`."
Test: LifecycleEventEffectTest
Bug: 235529345
Change-Id: Ic9794d7e59b1a66cc7f31cbaebed9b3d3dee5dd3
M lifecycle/lifecycle-runtime-compose/api/current.txt
M lifecycle/lifecycle-runtime-compose/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-runtime-compose/api/restricted_current.txt
M lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/CollectAsStateWithLifecycleTests.kt
A lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleEffectTest.kt
M lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleExtTest.kt
A lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleEffect.kt
ap...@google.com <ap...@google.com> #11
Branch: androidx-main
commit 25a2002ab933ea551295483aa3f7e278d60dbe75
Author: sanura <sanura@google.com>
Date: Wed May 03 20:20:56 2023
Create LifecycleResumeEffect composable
Adding LifecycleResumeEffect composable API to be used when
running SideEffects based on ON_RESUME/ON_PAUSE event callbacks.
RelNote: "`LifecycleResumeEffect` API has been added to run side
effects based on both `Lifecycle.Event.ON_RESUME` and
`Lifecycle.Event.ON_PAUSE` event callbacks."
Test: lifecycleResumeEffectTest
Bug: 235529345
Change-Id: I603860f21eb6a433c909d7ae6f8120f6d23179aa
M lifecycle/lifecycle-runtime-compose/api/current.txt
M lifecycle/lifecycle-runtime-compose/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-runtime-compose/api/restricted_current.txt
M lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleEffectTest.kt
M lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleEffect.kt
ap...@google.com <ap...@google.com> #12
Branch: androidx-main
commit 2b090a54b8182927eb0e96062e0a14d065a8561a
Author: sanura <sanura@google.com>
Date: Tue May 02 19:53:55 2023
Create LifecycleStartEffect composable
Adding LifecycleStartEffect composable API to be used when
running SideEffects based on ON_START/ON_STOP event callbacks.
RelNote: "`LifecycleStartEffect` API has been added to run side
effects based on `Lifecycle.Event.ON_START` and
`Lifecycle.Event.ON_STOP` event callbacks."
Test: lifecycleStartEffectTest
Bug: 235529345
Change-Id: I5a8d1e6f152b7083e086146ba97044c4b454db84
M lifecycle/lifecycle-runtime-compose/api/current.txt
M lifecycle/lifecycle-runtime-compose/api/public_plus_experimental_current.txt
M lifecycle/lifecycle-runtime-compose/api/restricted_current.txt
M lifecycle/lifecycle-runtime-compose/src/androidTest/java/androidx/lifecycle/compose/LifecycleEffectTest.kt
M lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleEffect.kt
st...@gmail.com <st...@gmail.com> #13
Is there a target API version where this may be released?
il...@google.com <il...@google.com> #14
This is still in progress for inclusion in Lifecycle 2.7.0-alpha01.
ap...@google.com <ap...@google.com> #15
Branch: androidx-main
commit ad273fa4882a38a5a2f72004044ce3173b2c06a9
Author: sanura <sanura@google.com>
Date: Fri May 05 02:02:59 2023
Add samples for LifecycleEffects
Adding samples for LifecycleEventEffect,
LifecycleStartEffect, and LifecycleResumeEffect.
RelNote: "All composables in `LifecycleEffect` now
link sample usages."
Test: ./gradlew bOS
Bug: 235529345
Change-Id: Ib4786f4b586cf9390f3dbe6f3b0fc86c60267a86
M lifecycle/lifecycle-runtime-compose/samples/src/main/java/androidx/lifecycle/compose/samples/LifecycleComposeSamples.kt
M lifecycle/lifecycle-runtime-compose/src/main/java/androidx/lifecycle/compose/LifecycleEffect.kt
sa...@google.com <sa...@google.com>
lm...@gmail.com <lm...@gmail.com> #16
ka...@gmail.com <ka...@gmail.com> #17
When will this be released?
na...@google.com <na...@google.com> #18
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.lifecycle:lifecycle-runtime-compose:2.7.0-alpha01
sj...@gmail.com <sj...@gmail.com> #19
Just want to say that Lifecycle 2.7.0
stable has been finally released. Thank you very much 🙏🏼
ey...@gmail.com <ey...@gmail.com> #20
jb...@google.com <jb...@google.com> #21
Yes, those are the Lifecycle.State
s that reflect those particular Lifecycle.Event
s. Please take a look at the
ey...@gmail.com <ey...@gmail.com> #22
jb...@google.com <jb...@google.com> #23
Receiving a state from the flow would be the signal that a change has occurred and the new state is that particular change. There are cases where you don't care how you get to a state, just that you are there. We also offer Lifecycle.Event
s.
il...@google.com <il...@google.com> #24
If you look at the Lifecycle.asFlow()
to get a Flow of Lifecycle.Event
) and one for Lifecycle State (where you can use Lifecycle.currentStateFlow
to get the current Lifecycle.State
).
Make sure you are using the right API.
ey...@gmail.com <ey...@gmail.com> #25
il...@google.com <il...@google.com> #26
Lifecycle.asFlow()
works outside of Compose too and gives you Lifecycle.Event
instances as they occur. That's why that API exists separately from currentStateFlow
.
Description
Component used: Lifecycle
Version used: 2.5.0-rc01
Reacting to a Lifecycle.State changes is currently fairly complicated in a Jetpack Compose based app, requiring a with registering a
DisposableEffect
based approachLifecycleObserver
with theLocalLifecycleOwner
.Ideally, this would come in two forms:
Lifecycle.State
asState
, perhaps something likeLocalLifecycleOwner.current.lifecycle.currentStateFlow.collectAsState()
LifecycleEventEffect
that would only run the effect when theLifecycle.State
changes.