Skip to content

Commit

Permalink
Bump to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensousa committed Nov 11, 2018
1 parent a11abc2 commit dae807b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -29,23 +28,21 @@ 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:

```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.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit dae807b

Please sign in to comment.