Repository: Automattic/pocket-casts-android
File: modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/PlayerBottomSheet.kt (Kotlin)

Code before:
                listener?.onPlayerBottomSheetSlide(bottomSheet, slideOffset)

                animations?.forEach { it.onSlide(slideOffset) }
            }

            override fun onStateChanged(bottomSheet: View, newState: Int) {
                settings.updatePlayerOrUpNextBottomSheetState(newState)
                when (newState) {
                    BottomSheetBehavior.STATE_COLLAPSED -> onCollapsed()
                    BottomSheetBehavior.STATE_DRAGGING -> onDragging()
                    BottomSheetBehavior.STATE_SETTLING -> onSettling()
                    BottomSheetBehavior.STATE_EXPANDED -> onExpanded()
                }
            }
        }
    }

    private fun createPreFlingInterceptor(
        behavior: BottomSheetBehavior<*>,
    ) = object : PreFlingInterceptor {
        override fun shouldInterceptFlingGesture(velocityX: Float, velocityY: Float): Boolean {
            return velocityY in -4000f..0f
        }

        override fun onFlingIntercepted(velocityX: Float, velocityY: Float) {
            behavior.state = if (velocityY >= 0f) {
                BottomSheetBehavior.STATE_COLLAPSED
            } else {
                BottomSheetBehavior.STATE_EXPANDED
            }
        }
    }

    private fun onCollapsed() {
        listener?.onPlayerClosed()
        animations?.forEach { it.onCollapsed() }
        analyticsTracker.track(AnalyticsEvent.PLAYER_DISMISSED)

        binding.player.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
        binding.miniPlayer.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_YES
    }

    private fun onDragging() {
        animations?.forEach { it.onDragging() }
    }

    private fun onSettling() {
        animations?.forEach { it.onSettling() }
    }

    private fun onExpanded() {

Review comment (suggestion):
```suggestion
            behavior.state = if (velocityY > 0f) {
```

Code after:
                listener?.onPlayerBottomSheetSlide(bottomSheet, slideOffset)

                animations?.forEach { it.onSlide(slideOffset) }
            }

            override fun onStateChanged(bottomSheet: View, newState: Int) {
                settings.updatePlayerOrUpNextBottomSheetState(newState)
                when (newState) {
                    BottomSheetBehavior.STATE_COLLAPSED -> onCollapsed()
                    BottomSheetBehavior.STATE_DRAGGING -> onDragging()
                    BottomSheetBehavior.STATE_SETTLING -> onSettling()
                    BottomSheetBehavior.STATE_EXPANDED -> onExpanded()
                }
            }
        }
    }

    private fun createPreFlingInterceptor(
        behavior: BottomSheetBehavior<*>,
    ) = object : PreFlingInterceptor {
        override fun shouldInterceptFlingGesture(velocityX: Float, velocityY: Float): Boolean {
            return behavior.calculateSlideOffset() > 0.75f && velocityY in -4000f..0f
        }

        override fun onFlingIntercepted(velocityX: Float, velocityY: Float) {
            behavior.state = if (velocityY > 0f) {
                BottomSheetBehavior.STATE_COLLAPSED
            } else {
                BottomSheetBehavior.STATE_EXPANDED
            }
        }
    }

    private fun onCollapsed() {
        listener?.onPlayerClosed()
        animations?.forEach { it.onCollapsed() }
        analyticsTracker.track(AnalyticsEvent.PLAYER_DISMISSED)

        binding.player.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
        binding.miniPlayer.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_YES
    }

    private fun onDragging() {
        animations?.forEach { it.onDragging() }
    }

    private fun onSettling() {
        animations?.forEach { it.onSettling() }
    }

    private fun onExpanded() {