commit | f0084673d0d7518e246241ffb99737ddf036e64f | [log] [tgz] |
---|---|---|
author | Aga Madurska <amad@google.com> | Thu Sep 22 13:50:02 2016 +0100 |
committer | Aga Madurska <amad@google.com> | Thu Sep 22 13:51:50 2016 +0100 |
tree | 8e5d580eaf21596447c9d5fa1ec32985c0fd2957 | |
parent | ae1b0bdaae9e716a2292055458eb178fa52398c2 [diff] |
Correctly account for negative fling directions. Bug:31640199 Change-Id: I31376cc42a2f4faa95ec16cbfba64e4a2a50ee7e
diff --git a/v7/recyclerview/src/android/support/v7/widget/LinearSnapHelper.java b/v7/recyclerview/src/android/support/v7/widget/LinearSnapHelper.java index 4b37c68..9e262db 100644 --- a/v7/recyclerview/src/android/support/v7/widget/LinearSnapHelper.java +++ b/v7/recyclerview/src/android/support/v7/widget/LinearSnapHelper.java
@@ -170,7 +170,11 @@ } int distance = Math.abs(distances[0]) > Math.abs(distances[1]) ? distances[0] : distances[1]; - return (int) Math.floor(distance / distancePerChild); + if (distance > 0) { + return (int) Math.floor(distance / distancePerChild); + } else { + return (int) Math.ceil(distance / distancePerChild); + } } /**