From c33c7a2a45e98041143a7dd101ee75bf79c3826f Mon Sep 17 00:00:00 2001 From: ruben Date: Sat, 17 Aug 2019 13:32:11 +0100 Subject: [PATCH] Expose current snapped position --- .../github/rubensousa/gravitysnaphelper/GravityDelegate.java | 4 ++++ .../rubensousa/gravitysnaphelper/GravityPagerSnapHelper.java | 4 ++++ .../rubensousa/gravitysnaphelper/GravitySnapHelper.java | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityDelegate.java b/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityDelegate.java index 1111892..8f0f886 100644 --- a/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityDelegate.java +++ b/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityDelegate.java @@ -80,6 +80,10 @@ public void attachToRecyclerView(@Nullable RecyclerView recyclerView) { } } + public int getCurrentSnappedPosition() { + return currentSnappedPosition; + } + public void smoothScrollToPosition(int position) { scrollTo(position, true); } diff --git a/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityPagerSnapHelper.java b/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityPagerSnapHelper.java index fcceb09..9ba18df 100644 --- a/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityPagerSnapHelper.java +++ b/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityPagerSnapHelper.java @@ -89,4 +89,8 @@ public void scrollToPosition(int position) { delegate.scrollToPosition(position); } + public int getCurrentSnappedPosition() { + return delegate.getCurrentSnappedPosition(); + } + } diff --git a/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravitySnapHelper.java b/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravitySnapHelper.java index fe973d7..179ab15 100644 --- a/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravitySnapHelper.java +++ b/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravitySnapHelper.java @@ -79,6 +79,10 @@ public void scrollToPosition(int position) { delegate.scrollToPosition(position); } + public int getCurrentSnappedPosition() { + return delegate.getCurrentSnappedPosition(); + } + public interface SnapListener { void onSnap(int position); }