Status Update
Comments
il...@google.com <il...@google.com>
da...@google.com <da...@google.com> #2
il...@google.com <il...@google.com>
da...@google.com <da...@google.com> #3
da...@google.com <da...@google.com> #4
Branch: androidx-master-dev
commit d3c7e85f798b804ef66da955f79f2d162aa20452
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Dec 17 11:27:36 2019
Ensure StrictFragment does not ascend state with destroyed activity
Added a check to make sure that when a StrictFragment is going up in
state, its activity is not destroyed. Put checks in onCreateView and
onCreatedView of StrictViewFragment too.
Test: all tests pass
BUG: 144309266
Change-Id: Iefe2031c0c40ba603dd83d257a255bf5df278dc3
M fragment/fragment/src/androidTest/java/androidx/fragment/app/StrictViewFragment.kt
M testutils/testutils-runtime/src/main/java/androidx/fragment/app/StrictFragment.kt
jb...@google.com <jb...@google.com> #5
Branch: androidx-master-dev
commit c03c0e0ebfaca4b1b342dad0270489107ea4c73d
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Dec 17 11:35:33 2019
Change FragmentFinishEarlyTest to use StrictFragment
The goal of the FragmentFinishEarlyTest is to ensure that the Fragment
state is not raised while the activity is being destroyed.
StrictFragment now checks if the activity is being destroyed in all of
the upward states (onCreate, onStart, etc.) so we should just use that
instead of a custom Fragment with booleans.
Test: all tests pass
BUG: 144309266
Change-Id: Ic47a178c50bcbba246b91e2e25d969dd6931d765
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentFinishEarlyTest.kt
jb...@google.com <jb...@google.com>
da...@google.com <da...@google.com> #6
Branch: androidx-master-dev
commit 3d9b247656fd46ebd17b1cd9743e163afe85f3d6
Author: Ian Lake <ilake@google.com>
Date: Thu Jan 09 11:15:06 2020
Remove most usages of onActivityCreated()
Update demos and tests to use onViewCreated()
instead of onActivityCreated().
Test: ./gradlew bOS
BUG: 144309266
Change-Id: Icc0d43554f014c42db1068dfe6410cc191e21818
M fragment/fragment/src/androidTest/java/androidx/fragment/app/LoaderTest.kt
M samples/Support4Demos/src/main/java/com/example/android/supportv4/app/FragmentLayoutSupport.java
M samples/Support4Demos/src/main/java/com/example/android/supportv4/app/FragmentListArraySupport.java
M samples/Support4Demos/src/main/java/com/example/android/supportv4/app/FragmentPagerSupport.java
M samples/Support4Demos/src/main/java/com/example/android/supportv4/app/FragmentStatePagerSupport.java
M samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCursorSupport.java
M samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderCustomSupport.java
M samples/Support4Demos/src/main/java/com/example/android/supportv4/app/LoaderThrottleSupport.java
da...@google.com <da...@google.com> #7
jb...@google.com <jb...@google.com> #8
With the removal of this what is the proper and easy way to know when the view is actually attached to parent?
Going edge to edge with BottomSheetDialogFragment force us to get the view parents to disable fitsSystemWindows and handling this properly.
Unfortunately the view is not yet attached during the call to onViewCreated and onActivityCreated is the best place.
From your initial post I suppose onViewStateRestored is the new proper callback, but the name is counter intuitive and I initially thought that this would not have been called on first creation as nothing to restore.
ap...@google.com <ap...@google.com> #9
Re #8 - onActivityCreated()
runs onViewCreated()
, so the state you're in would be exactly the same between the two calls.
We've been meaning to make it more consistent whether you're attached or not in onViewCreated()
for a while here (as it turns out right now you could be in either case), I've created
jb...@google.com <jb...@google.com> #10
It seems the new beta tracker does not automatically watch issues on comment did not receive this answer :(.
Anyway with Fragment 1.2.1 in BottomSheetDialogFragment this is not the case.
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
logError("TAG") { "onActivityCreated: ${view?.parent?.parent?.parent}" }
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
logError("TAG") { "onViewCreated: ${this.view?.parent?.parent?.parent}" }
logError("TAG") { "onViewCreated: ${view.parent?.parent?.parent}" }
}
override fun onViewStateRestored(savedInstanceState: Bundle?) {
super.onViewStateRestored(savedInstanceState)
logError("TAG") { "onViewStateRestored: ${this.view?.parent?.parent?.parent}" }
}
Always and consistently gives:
2020-02-10 18:48:24.498 31061-31130/XXX E/TAG: BaseBottomSheetDialogFragment.onViewCreated@63: onViewCreated: null
2020-02-10 18:48:24.499 31061-31130/XXX E/TAG: BaseBottomSheetDialogFragment.onViewCreated@64: onViewCreated: null
2020-02-10 18:48:24.519 31061-31129/XXX E/TAG: BaseBottomSheetDialogFragment.onActivityCreated@58: onActivityCreated: android.widget.FrameLayout{f46459f V.E...... ......I. 0,0-0,0 #7f0a0137 app:id/container}
2020-02-10 18:48:24.520 31061-31129/XXX E/TAG: BaseBottomSheetDialogFragment.onViewStateRestored@70: onViewStateRestored: android.widget.FrameLayout{f46459f V.E...... ......I. 0,0-0,0 #7f0a0137 app:id/container}
da...@google.com <da...@google.com> #11
So Ian the issue is about DialogFragment:
Seems this is also not changed in your 1.3.0 commit listed here, would be nice that it is and that onViewCreated works in that case too if possible or find a proper common ways that works for all cases.
Description
Component used:
When using the above components together, there are two problems:
GuidedSupportFragment.add
.When using Fragment 1.2.5, there is no problem.
Sample project attached.