Recycler Scroll State View
A custom RecyclerView that provides edge reach and scroll direction detection.
This view extends RecyclerView and adds functionality to detect when the user has scrolled to the edge of the view and the direction of the scroll.
가장자리 도달 및 스크롤 방향 감지 기능을 제공하는 커스텀 RecyclerView입니다.
이 뷰는 RecyclerView를 확장하여 사용자가 뷰의 가장자리로 스크롤했을 때와 스크롤 방향을 감지하는 기능을 추가합니다.
Features:
Detects when scroll reaches top, bottom, left, or right edges
Tracks scroll direction (UP, DOWN, LEFT, RIGHT, IDLE)
Supports both listener callbacks and Kotlin Flow
Configurable thresholds for edge detection and direction sensitivity
Automatic lifecycle management for scroll listeners
기능:스크롤이 상단, 하단, 좌측, 우측 가장자리에 도달하는지 감지
스크롤 방향 추적 (UP, DOWN, LEFT, RIGHT, IDLE)
리스너 콜백과 Kotlin Flow 모두 지원
가장자리 감지 및 방향 민감도에 대한 구성 가능한 임계값
스크롤 리스너의 자동 생명주기 관리
Usage example:
val recyclerView = RecyclerScrollStateView(context)
recyclerView.setOnScrollDirectionListener { direction ->
when (direction) {
ScrollDirection.UP -> // Handle scroll up
ScrollDirection.DOWN -> // Handle scroll down
else -> // Handle other directions
}
}
recyclerView.setOnReachEdgeListener { edge, isReached ->
if (edge == ScrollEdge.BOTTOM && isReached) {
// Load more items
}
}See also
For scroll direction types.
스크롤 방향 타입은 ScrollDirection을 참조하세요.
For edge position types.
가장자리 위치 타입은 ScrollEdge를 참조하세요.
For the scroll state calculation logic.
스크롤 상태 계산 로직은 RecyclerScrollStateCalculator를 참조하세요.
Properties
Public SharedFlow for observing edge reach events.
가장자리 도달 이벤트를 관찰하기 위한 공개 SharedFlow입니다.
Public SharedFlow for observing scroll direction changes.
스크롤 방향 변경을 관찰하기 위한 공개 SharedFlow입니다.
Functions
Binds a lifecycle observer to the current LifecycleOwner.
Replaces the observer if the owner changes, prevents duplicate registration.
현재 LifecycleOwner에 라이프사이클 옵저버를 바인딩합니다.
Owner가 변경되면 옵저버를 교체하고, 중복 등록을 방지합니다.
Executes a block when the view has been laid out and measured.
Useful for getting actual view dimensions.
View가 레이아웃되고 측정된 후 블록을 실행합니다.
실제 View 크기를 얻는 데 유용합니다.
Toggles visibility with fade animation.
페이드 애니메이션과 함께 가시성을 토글합니다.
Finds the host LifecycleOwner for this View.
Prioritizes Fragment's viewLifecycleOwner, falls back to Activity.
이 View의 호스트 LifecycleOwner를 찾습니다.
Fragment의 viewLifecycleOwner를 우선시하고, 없으면 Activity를 사용합니다.
Iterates over all child views of this ViewGroup.
이 ViewGroup의 모든 자식 View를 반복합니다.
Gets the view's location on screen as a Pair.
View의 화면상 위치를 Pair로 가져옵니다.
Sets the threshold distance (in pixels) from an edge that is considered as reaching the edge.
This method allows you to define the distance from an edge (top, bottom, left, or right) within which the RecyclerScrollStateView is considered to have reached that edge.
By default, the edge reach threshold is set to 10 pixels.
You can adjust this value to control the sensitivity of edge reach detection. A higher value will make the detection less sensitive, while a lower value will make it more sensitive.
가장자리에 도달한 것으로 간주되는 가장자리로부터의 임계 거리(픽셀 단위)를 설정합니다.
이 메서드를 사용하면 RecyclerScrollStateView가 해당 가장자리에 도달한 것으로 간주되는 가장자리(상단, 하단, 좌측 또는 우측)로부터의 거리를 정의할 수 있습니다.
기본값으로 가장자리 도달 임계값은 10픽셀로 설정됩니다.
이 값을 조정하여 가장자리 도달 감지의 민감도를 제어할 수 있습니다. 값이 높을수록 감지가 덜 민감해지고, 낮을수록 더 민감해집니다.
Sets the view's visibility to GONE.
View의 가시성을 GONE으로 설정합니다.
Sets the height of the view.
View의 높이를 설정합니다.
Sets the view height to match parent.
View의 높이를 부모에 맞춥니다.
Sets the view height to wrap content.
View의 높이를 내용에 맞춥니다.
Sets the view's visibility to INVISIBLE.
View의 가시성을 INVISIBLE로 설정합니다.
Sets uniform margin for all sides.
모든 면에 대해 동일한 여백을 설정합니다.
Sets all margin values at once.
모든 여백 값을 한 번에 설정합니다.
Sets a debounced click listener on this view to prevent rapid consecutive clicks.
Uses View's tag system to store timing information, preventing memory leaks.
연속적인 빠른 클릭을 방지하기 위해 디바운스된 클릭 리스너를 설정합니다.
View의 tag 시스템을 사용하여 타이밍 정보를 저장하여 메모리 누수를 방지합니다.
Sets a lambda listener to be notified when the RecyclerView reaches an edge.
RecyclerView가 가장자리에 도달했을 때 알림을 받을 람다 리스너를 설정합니다.
Sets a listener to be notified when the RecyclerView reaches an edge.
This method allows you to register a callback that will be invoked whenever the RecyclerScrollStateView reaches one of its edges: top, bottom, left, or right.
The edge reach detection is determined based on the configured edgeReachThreshold.
RecyclerView가 가장자리에 도달했을 때 알림을 받을 리스너를 설정합니다.
이 메서드를 사용하면 RecyclerScrollStateView가 상단, 하단, 좌측, 우측 가장자리 중 하나에 도달할 때마다 호출될 콜백을 등록할 수 있습니다.
가장자리 도달 감지는 구성된 edgeReachThreshold를 기반으로 결정됩니다.
Sets a lambda listener to be notified of scroll direction changes.
스크롤 방향 변경 알림을 받을 람다 리스너를 설정합니다.
Sets a listener to be notified of scroll direction changes.
This method allows you to register a callback that will be invoked whenever the scroll direction of the RecyclerScrollStateView changes.
The scroll direction is determined based on the accumulated scroll distance and the configured scrollDirectionThreshold.
스크롤 방향 변경 알림을 받을 리스너를 설정합니다.
이 메서드를 사용하면 RecyclerScrollStateView의 스크롤 방향이 변경될 때마다 호출될 콜백을 등록할 수 있습니다.
스크롤 방향은 축적된 스크롤 거리와 구성된 scrollDirectionThreshold를 기반으로 결정됩니다.
Sets uniform padding for all sides.
모든 면에 대해 동일한 패딩을 설정합니다.
Sets the minimum scroll movement range required to trigger a scroll direction change event.
This method allows you to define the minimum distance (in pixels) that the RecyclerScrollStateView must be scrolled in a particular direction before a scroll direction change event is triggered.
By default, the minimum scroll movement range is set to 20 pixels.
You can adjust this value to control the sensitivity of scroll direction detection. A higher value will make the detection less sensitive, while a lower value will make it more sensitive.
스크롤 방향 변경 이벤트를 트리거하는 데 필요한 최소 스크롤 이동 범위(px)를 설정합니다.
이 메서드를 사용하면 스크롤 방향 변경 이벤트가 트리거되기 전에 RecyclerScrollStateView가 특정 방향으로 스크롤되어야 하는 최소 거리(픽셀 단위)를 정의할 수 있습니다.
기본값으로 최소 스크롤 이동 범위는 20픽셀로 설정됩니다.
이 값을 조정하여 스크롤 방향 감지의 민감도를 제어할 수 있습니다. 값이 높을수록 감지가 덜 민감해지고, 낮을수록 더 민감해집니다.
Sets the view's visibility to VISIBLE.
View의 가시성을 VISIBLE로 설정합니다.
Sets the width of the view.
View의 너비를 설정합니다.
Sets the view width to match parent.
View의 너비를 부모에 맞춥니다.
Sets the view width to wrap content.
View의 너비를 내용에 맞춥니다.
Creates an indefinite duration Snackbar without showing it.
The Snackbar will remain visible until dismissed.
표시하지 않고 무제한 시간 Snackbar를 생성합니다.
Snackbar는 닫힐 때까지 계속 표시됩니다.
Creates a long duration Snackbar without showing it.
Allows further customization before displaying.
표시하지 않고 긴 시간 Snackbar를 생성합니다.
표시하기 전에 추가 커스터마이징이 가능합니다.
Creates a short duration Snackbar without showing it.
Allows further customization before displaying.
표시하지 않고 짧은 시간 Snackbar를 생성합니다.
표시하기 전에 추가 커스터마이징이 가능합니다.
Creates and shows an indefinite duration Snackbar from a View.
View에서 무제한 시간 Snackbar를 생성하고 표시합니다.
Creates and shows an indefinite duration Snackbar with a custom view.
커스텀 뷰로 무제한 시간 Snackbar를 생성하고 표시합니다.
Creates and shows a long duration Snackbar from a View.
View에서 긴 시간 Snackbar를 생성하고 표시합니다.
Creates and shows a long duration Snackbar with a custom view.
커스텀 뷰로 긴 시간 Snackbar를 생성하고 표시합니다.
Creates and shows a short duration Snackbar from a View.
View에서 짧은 시간 Snackbar를 생성하고 표시합니다.
Creates and shows a short duration Snackbar with a custom view.
커스텀 뷰로 짧은 시간 Snackbar를 생성하고 표시합니다.
Unbinds the lifecycle observer from this View.
Should be called when detaching the view or changing parent.
이 View에서 라이프사이클 옵저버를 언바인딩합니다.
View를 분리하거나 부모를 변경할 때 호출해야 합니다.