Skip to content

Commit

Permalink
Remove Kotlin Delegate feature for AOSPLithoVisibilityEventsController
Browse files Browse the repository at this point in the history
Summary: Remove Kotlin Delegate feature for AOSPLithoVisibilityEventsController

Reviewed By: adityasharat

Differential Revision: D58524072

fbshipit-source-id: 1e818737ae5f4db14b17c4937083c495a589070c
  • Loading branch information
jettbow authored and facebook-github-bot committed Jun 14, 2024
1 parent cbe99d3 commit 55aae90
Showing 1 changed file with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,30 @@ import com.facebook.litho.LithoVisibilityEventsController.LithoVisibilityState
* passed as param, the observers will be registered to listen to all of the fragment's lifecycle
* state changes.
*/
open class AOSPLithoVisibilityEventsController(
final override val lifecycleOwner: LifecycleOwner,
private val delegate: LithoVisibilityEventsControllerDelegate =
LithoVisibilityEventsControllerDelegate()
) :
LithoVisibilityEventsController by delegate,
LifecycleEventObserver,
AOSPLifecycleOwnerProvider {
open class AOSPLithoVisibilityEventsController(final override val lifecycleOwner: LifecycleOwner) :
LithoVisibilityEventsController, LifecycleEventObserver, AOSPLifecycleOwnerProvider {

private val delegate: LithoVisibilityEventsControllerDelegate =
LithoVisibilityEventsControllerDelegate()

init {
lifecycleOwner.lifecycle.addObserver(this)
}

constructor(
lifecycleOwner: LifecycleOwner
) : this(lifecycleOwner = lifecycleOwner, delegate = LithoVisibilityEventsControllerDelegate())
override val visibilityState: LithoVisibilityState
get() = delegate.visibilityState

override fun moveToVisibilityState(newVisibilityState: LithoVisibilityState) {
delegate.moveToVisibilityState(newVisibilityState)
}

override fun addListener(listener: LithoVisibilityEventsListener) {
delegate.addListener(listener)
}

override fun removeListener(listener: LithoVisibilityEventsListener) {
delegate.removeListener(listener)
}

override fun onStateChanged(source: LifecycleOwner, event: Event) {
when (event) {
Expand Down

0 comments on commit 55aae90

Please sign in to comment.