@@ -33,16 +33,15 @@ class PageViewFragmentDelegate<T>(
3333
3434 private val visibilityTracker = PageViewVisibilityTracker ()
3535 private val pageViewAnnotationProcessor by lazy {
36- val pageViewUtils = EarlyEntryPoints .get(
37- fragment.requireActivity().applicationContext,
38- PageViewEntryPoint ::class .java
39- ).pageViewUtils()
40- PageViewAnnotationProcessor (fragment::class .java, fragment, pageViewUtils)
36+ fragment.activity?.applicationContext?.let {
37+ val pageViewUtils = EarlyEntryPoints .get(it, PageViewEntryPoint ::class .java).pageViewUtils()
38+ PageViewAnnotationProcessor (fragment::class .java, fragment, pageViewUtils)
39+ }
4140 }
4241
4342 fun completePageViewPrerequisite (prerequisite : String ) {
4443 if (visibilityTracker.trackCustom(prerequisite, true , fragment)) {
45- pageViewAnnotationProcessor.startEvent()
44+ pageViewAnnotationProcessor? .startEvent()
4645 }
4746 }
4847
@@ -63,39 +62,39 @@ class PageViewFragmentDelegate<T>(
6362
6463 fun onHiddenChanged (hidden : Boolean ) {
6564 if (visibilityTracker.trackHidden(hidden, fragment)) {
66- pageViewAnnotationProcessor.startEvent()
65+ pageViewAnnotationProcessor? .startEvent()
6766 } else {
68- pageViewAnnotationProcessor.stopEvent()
67+ pageViewAnnotationProcessor? .stopEvent()
6968 }
7069 }
7170
7271 @Deprecated(" See description in superclass" )
7372 fun setUserVisibleHint (isVisibleToUser : Boolean ) {
7473 if (fragment.isAdded) {
7574 if (visibilityTracker.trackUserHint(isVisibleToUser, fragment)) {
76- pageViewAnnotationProcessor.startEvent()
75+ pageViewAnnotationProcessor? .startEvent()
7776 } else {
78- pageViewAnnotationProcessor.stopEvent()
77+ pageViewAnnotationProcessor? .stopEvent()
7978 }
8079 }
8180 }
8281
8382 fun onResume () {
8483 if (visibilityTracker.trackResume(true , fragment)) {
85- pageViewAnnotationProcessor.startEvent()
84+ pageViewAnnotationProcessor? .startEvent()
8685 }
8786 }
8887
8988 fun onPause () {
9089 visibilityTracker.trackResume(false , fragment)
91- pageViewAnnotationProcessor.stopEvent()
90+ pageViewAnnotationProcessor? .stopEvent()
9291 }
9392
9493 fun onPageViewWindowFocusChanged (hasFocus : Boolean ) {
9594 if (visibilityTracker.trackCustom(" windowFocus" , hasFocus, fragment)) {
96- pageViewAnnotationProcessor.startEvent()
95+ pageViewAnnotationProcessor? .startEvent()
9796 } else {
98- pageViewAnnotationProcessor.stopEvent()
97+ pageViewAnnotationProcessor? .stopEvent()
9998 }
10099 }
101- }
100+ }
0 commit comments