Skip to content

Instantly share code, notes, and snippets.

@ricknout
Last active June 21, 2020 00:00
Show Gist options
  • Save ricknout/43a5d80edae86f3758457ae7be4c0c42 to your computer and use it in GitHub Desktop.
Save ricknout/43a5d80edae86f3758457ae7be4c0c42 to your computer and use it in GitHub Desktop.
Change order of args to enable trailing lambda syntax
package com.nickrout.snaphelperlistener
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SnapHelper
fun RecyclerView.attachSnapHelperWithListener(
snapHelper: SnapHelper,
behavior: SnapOnScrollListener.Behavior = SnapOnScrollListener.Behavior.NOTIFY_ON_SCROLL,
onSnapPositionChangeListener: OnSnapPositionChangeListener) {
snapHelper.attachToRecyclerView(this)
val snapOnScrollListener = SnapOnScrollListener(snapHelper, onSnapPositionChangeListener, behavior)
addOnScrollListener(snapOnScrollListener)
}
@ricknout
Copy link
Author

ricknout commented Jan 8, 2019

Great point @nickbutcher, updated 👍

@asshyy-ktz
Copy link

Great point @nickbutcher, updated 👍

@ricknout where have you updated it? can you mention it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment