From dae807b802b0564556605aaaf33f237026c31734 Mon Sep 17 00:00:00 2001 From: ruben Date: Sun, 11 Nov 2018 19:37:50 +0000 Subject: [PATCH] Bump to 2.0 --- README.md | 17 +++++++---------- gradle.properties | 2 +- .../gravitysnaphelper/GravityDelegate.java | 7 +++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3a574aa..bd4e9e5 100644 --- a/README.md +++ b/README.md @@ -11,16 +11,15 @@ If you need snapping support to start, top, end or bottom, use GravitySnapHelper Add this to your build.gradle: ```groovy -implementation 'com.github.rubensousa:gravitysnaphelper:1.5' +implementation 'com.github.rubensousa:gravitysnaphelper:2.0' ``` -Otherwise, center snapping is done with LinearSnapHelper (part of the recyclerview-v7 package). +Otherwise, center snapping is done with LinearSnapHelper. ### Snapping center: ```java -SnapHelper snapHelper = new LinearSnapHelper(); -snapHelper.attachToRecyclerView(recyclerView); +new LinearSnapHelper().attachToRecyclerView(recyclerView); ``` ### Snapping start with GravitySnapHelper: @@ -29,8 +28,7 @@ snapHelper.attachToRecyclerView(recyclerView); startRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); -SnapHelper snapHelperStart = new GravitySnapHelper(Gravity.START); -snapHelperStart.attachToRecyclerView(startRecyclerView); +new GravitySnapHelper(Gravity.START).attachToRecyclerView(startRecyclerView); ``` ### Snapping top with GravitySnapHelper: @@ -38,14 +36,13 @@ snapHelperStart.attachToRecyclerView(startRecyclerView); ```java topRecyclerView.setLayoutManager(new LinearLayoutManager(this)); -SnapHelper snapHelperTop = new GravitySnapHelper(Gravity.TOP); -snapHelperTop.attachToRecyclerView(topRecyclerView); +new GravitySnapHelper(Gravity.TOP).attachToRecyclerView(topRecyclerView); ``` ## License - Copyright 2016 The Android Open Source Project - Copyright 2016 Rúben Sousa + Copyright 2018 The Android Open Source Project + Copyright 2018 Rúben Sousa Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/gradle.properties b/gradle.properties index 6a69fcc..f2b4a00 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true GROUP=com.github.rubensousa -VERSION_NAME=1.5 +VERSION_NAME=2.0 POM_ARTIFACT_ID=gravitysnaphelper POM_NAME=GravitySnapHelper 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 2c15108..ba37432 100644 --- a/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityDelegate.java +++ b/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/GravityDelegate.java @@ -199,10 +199,9 @@ private int distanceToEnd(View targetView, LinearLayoutManager lm, @NonNull OrientationHelper helper) { int pos = recyclerView.getChildLayoutPosition(targetView); int distance; - /** - * The last position or the first position - * (when there's a reverse layout or we're on RTL mode) must collapse to the padding edge. - */ + + // The last position or the first position + // (when there's a reverse layout or we're on RTL mode) must collapse to the padding edge. if ((pos == 0 && (isRtl || lm.getReverseLayout()) || pos == lm.getItemCount() - 1 && (!isRtl || lm.getReverseLayout())) && !recyclerView.getClipToPadding()) {