Fixed
Status Update
Comments
vi...@google.com <vi...@google.com>
ma...@bokhorst.biz <ma...@bokhorst.biz> #2
This lint check should apply to:
- onCreateView()
- onViewCreated()
- onActivityCreated()
- onViewStateRestored()
As all of those are called each time the fragment's view is created.
- onCreateView()
- onViewCreated()
- onActivityCreated()
- onViewStateRestored()
As all of those are called each time the fragment's view is created.
vi...@google.com <vi...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit d26126d23175fc55c77788b95989f1ecc873eb9c
Author: Matthew Fraschilla <fraschilla@google.com>
Date: Mon Oct 07 13:05:15 2019
Add lint check for unsafe livedata observe in Fragments
A Fragment's lifecycle can last longer than its view resulting in
LiveData objects being observed longer than intended. This change
introduces a lint check to warn developers that they should use the
getViewLifecyclOwner() method as the LifecycleOwner when observing
LiveData objects.
Test: new FragmentLiveDataObserveDetectorTest
Bug: 137122478
Change-Id: If002f6be74d9b943f1b43cf2515b20337489b704
A fragment/fragment-lint/src/main/java/androidx/fragment/lint/FragmentLiveDataObserverDetector.kt
A fragment/fragment-lint/src/main/java/androidx/fragment/lint/LintUtils.kt
A fragment/fragment-lint/src/test/java/androidx/fragment/lint/FragmentLiveDataObserveDetectorTest.kt
A fragment/fragment-lint/src/test/java/androidx/fragment/lint/stubs/Stubs.kt
https://android-review.googlesource.com/1137099
https://goto.google.com/android-sha1/d26126d23175fc55c77788b95989f1ecc873eb9c
Branch: androidx-master-dev
commit d26126d23175fc55c77788b95989f1ecc873eb9c
Author: Matthew Fraschilla <fraschilla@google.com>
Date: Mon Oct 07 13:05:15 2019
Add lint check for unsafe livedata observe in Fragments
A Fragment's lifecycle can last longer than its view resulting in
LiveData objects being observed longer than intended. This change
introduces a lint check to warn developers that they should use the
getViewLifecyclOwner() method as the LifecycleOwner when observing
LiveData objects.
Test: new FragmentLiveDataObserveDetectorTest
Bug: 137122478
Change-Id: If002f6be74d9b943f1b43cf2515b20337489b704
A fragment/fragment-lint/src/main/java/androidx/fragment/lint/FragmentLiveDataObserverDetector.kt
A fragment/fragment-lint/src/main/java/androidx/fragment/lint/LintUtils.kt
A fragment/fragment-lint/src/test/java/androidx/fragment/lint/FragmentLiveDataObserveDetectorTest.kt
A fragment/fragment-lint/src/test/java/androidx/fragment/lint/stubs/Stubs.kt
ma...@bokhorst.biz <ma...@bokhorst.biz> #4
We've added this Lint check internally and it will be available in Fragment 1.2.0-rc01
ru...@gmail.com <ru...@gmail.com> #5
vi...@google.com <vi...@google.com> #6
It seems the FragmentLiveDataObserve lint check is missing cases for, when one uses the observe extension function and not the observe function found on the LiveData class.
I created a repohttps://github.com/patrickusiewicz/missing-lint-check-for-observe to show the issue.
I created a repo
kc...@google.com <kc...@google.com>
cu...@google.com <cu...@google.com>
eu...@gmail.com <eu...@gmail.com> #7
Re #6 - please file a separate issue.
Description
java.lang.IllegalStateException: Cannot invoke setValue on a background thread at androidx.lifecycle.LiveData.assertMainThread(SourceFile:462) at androidx.lifecycle.LiveData.setValue(SourceFile:304) at androidx.lifecycle.MutableLiveData.setValue(SourceFile:50) at androidx.biometric.BiometricViewModel.setNegativeButtonPressPending(SourceFile:408) at androidx.biometric.BiometricViewModel$4.onClick(SourceFile:280) at android.hardware.biometrics.BiometricPrompt$1.lambda$onDialogDismissed$1(BiometricPrompt.java:231) at android.hardware.biometrics.-$$Lambda$BiometricPrompt$1$J5PqpiT8xZNiNN1gy9VraVgknaQ.run(Unknown:2) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764)