@@ -137,22 +137,22 @@ open class LithoNode : Node<LithoLayoutContext>, Cloneable {
137137 var nodeInfo: NodeInfo ? = null
138138 internal set
139139
140- var visibleHandler : EventHandler <VisibleEvent >? = null
140+ var onVisible : EventHandler <VisibleEvent >? = null
141141 internal set
142142
143- var focusedHandler : EventHandler <FocusedVisibleEvent >? = null
143+ var onFocusedVisible : EventHandler <FocusedVisibleEvent >? = null
144144 internal set
145145
146- var unfocusedHandler : EventHandler <UnfocusedVisibleEvent >? = null
146+ var onUnfocusedVisible : EventHandler <UnfocusedVisibleEvent >? = null
147147 internal set
148148
149- var fullImpressionHandler : EventHandler <FullImpressionVisibleEvent >? = null
149+ var onFullImpression : EventHandler <FullImpressionVisibleEvent >? = null
150150 internal set
151151
152- var invisibleHandler : EventHandler <InvisibleEvent >? = null
152+ var onInvisible : EventHandler <InvisibleEvent >? = null
153153 internal set
154154
155- var visibilityChangedHandler : EventHandler <VisibilityChangedEvent >? = null
155+ var onVisibilityChanged : EventHandler <VisibilityChangedEvent >? = null
156156 internal set
157157
158158 var background: Drawable ? = null
@@ -680,28 +680,13 @@ open class LithoNode : Node<LithoLayoutContext>, Cloneable {
680680 flexDirection = direction
681681 }
682682
683- fun focusedHandler (focusedHandler : EventHandler <FocusedVisibleEvent >? ) {
684- privateFlags = privateFlags or PFLAG_FOCUSED_HANDLER_IS_SET
685- this .focusedHandler = addVisibilityHandler(this .focusedHandler, focusedHandler)
686- }
687-
688683 fun layerType (@LayerType type : Int , paint : Paint ? ) {
689684 if (type != LayerType .LAYER_TYPE_NOT_SET ) {
690685 layerType = type
691686 layerPaint = paint
692687 }
693688 }
694689
695- fun visibilityOutputTag (visibilityOutputTag : String? ) {
696- this .visibilityOutputTag = visibilityOutputTag
697- }
698-
699- fun fullImpressionHandler (fullImpressionHandler : EventHandler <FullImpressionVisibleEvent >? ) {
700- privateFlags = privateFlags or PFLAG_FULL_IMPRESSION_HANDLER_IS_SET
701- this .fullImpressionHandler =
702- addVisibilityHandler(this .fullImpressionHandler, fullImpressionHandler)
703- }
704-
705690 fun getChildAt (index : Int ): LithoNode = children[index]
706691
707692 fun mutableNodeInfo (): NodeInfo {
@@ -758,20 +743,6 @@ open class LithoNode : Node<LithoLayoutContext>, Cloneable {
758743
759744 fun hasTransitionKey (): Boolean = ! transitionKey.isNullOrEmpty()
760745
761- fun hasVisibilityHandlers (): Boolean =
762- visibleHandler != null ||
763- focusedHandler != null ||
764- unfocusedHandler != null ||
765- fullImpressionHandler != null ||
766- invisibleHandler != null ||
767- visibilityChangedHandler != null
768-
769- fun invisibleHandler (invisibleHandler : EventHandler <InvisibleEvent >? ): LithoNode {
770- privateFlags = privateFlags or PFLAG_INVISIBLE_HANDLER_IS_SET
771- this .invisibleHandler = addVisibilityHandler(this .invisibleHandler, invisibleHandler)
772- return this
773- }
774-
775746 fun justifyContent (justifyContent : YogaJustify ) {
776747 this .justifyContent = justifyContent
777748 }
@@ -817,20 +788,35 @@ open class LithoNode : Node<LithoLayoutContext>, Cloneable {
817788 transitionKeyType = type
818789 }
819790
820- fun unfocusedHandler ( unfocusedHandler : EventHandler <UnfocusedVisibleEvent >? ) {
791+ fun addUnfocusedVisibleEventListener ( callback : EventHandler <UnfocusedVisibleEvent >? ) {
821792 privateFlags = privateFlags or PFLAG_UNFOCUSED_HANDLER_IS_SET
822- this .unfocusedHandler = addVisibilityHandler(this .unfocusedHandler, unfocusedHandler )
793+ this .onUnfocusedVisible = addVisibilityHandler(this .onUnfocusedVisible, callback )
823794 }
824795
825- fun visibilityChangedHandler ( visibilityChangedHandler : EventHandler <VisibilityChangedEvent >? ) {
796+ fun addVisibilityChangedEventListener ( callback : EventHandler <VisibilityChangedEvent >? ) {
826797 privateFlags = privateFlags or PFLAG_VISIBLE_RECT_CHANGED_HANDLER_IS_SET
827- this .visibilityChangedHandler =
828- addVisibilityHandler(this .visibilityChangedHandler, visibilityChangedHandler)
798+ this .onVisibilityChanged = addVisibilityHandler(this .onVisibilityChanged, callback)
829799 }
830800
831- fun visibleHandler ( visibleHandler : EventHandler <VisibleEvent >? ) {
801+ fun addVisibleEventListener ( callback : EventHandler <VisibleEvent >? ) {
832802 privateFlags = privateFlags or PFLAG_VISIBLE_HANDLER_IS_SET
833- this .visibleHandler = addVisibilityHandler(this .visibleHandler, visibleHandler)
803+ this .onVisible = addVisibilityHandler(this .onVisible, callback)
804+ }
805+
806+ fun addInvisibleEventListener (callback : EventHandler <InvisibleEvent >? ): LithoNode {
807+ privateFlags = privateFlags or PFLAG_INVISIBLE_HANDLER_IS_SET
808+ this .onInvisible = addVisibilityHandler(this .onInvisible, callback)
809+ return this
810+ }
811+
812+ fun addFocusedVisibleEventListener (callback : EventHandler <FocusedVisibleEvent >? ) {
813+ privateFlags = privateFlags or PFLAG_FOCUSED_HANDLER_IS_SET
814+ this .onFocusedVisible = addVisibilityHandler(this .onFocusedVisible, callback)
815+ }
816+
817+ fun addFullImpressionEventListener (callback : EventHandler <FullImpressionVisibleEvent >? ) {
818+ privateFlags = privateFlags or PFLAG_FULL_IMPRESSION_HANDLER_IS_SET
819+ this .onFullImpression = addVisibilityHandler(this .onFullImpression, callback)
834820 }
835821
836822 fun visibleHeightRatio (visibleHeightRatio : Float ) {
@@ -841,6 +827,18 @@ open class LithoNode : Node<LithoLayoutContext>, Cloneable {
841827 this .visibleWidthRatio = visibleWidthRatio
842828 }
843829
830+ fun hasVisibilityHandlers (): Boolean =
831+ onVisible != null ||
832+ onFocusedVisible != null ||
833+ onUnfocusedVisible != null ||
834+ onFullImpression != null ||
835+ onInvisible != null ||
836+ onVisibilityChanged != null
837+
838+ fun visibilityOutputTag (visibilityOutputTag : String? ) {
839+ this .visibilityOutputTag = visibilityOutputTag
840+ }
841+
844842 fun wrap (wrap : YogaWrap ) {
845843 yogaWrap = wrap
846844 }
0 commit comments