Skip to content

Commit

Permalink
Fix duration-time in ScrollerHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
xenione committed Mar 8, 2017
1 parent d371632 commit bf6239c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.2.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 21 11:34:03 PDT 2015
#Wed Mar 08 19:59:05 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,27 @@
*/
public class ScrollerHelper {

private static final int SCROLL_ANIMATION_DURATION = 3 * 1000;

private OverScroller mScroller;

public ScrollerHelper(Context context) {
mScroller = new OverScroller(context);
}

public boolean startScroll(int startX, int endX) {
if (startX == endX) {
public boolean startScroll(int start, int end) {
if (start == end) {
return false;
}
int delta = end - start;
mScroller.startScroll(start, 0, delta, 0);
return true;
}

public boolean startScroll(int start, int end, int duration) {
if (start == end) {
return false;
}
int deltaX = endX - startX;
mScroller.startScroll(startX, 0, deltaX, SCROLL_ANIMATION_DURATION);
int delta = end - start;
mScroller.startScroll(start, 0, delta, 0, duration);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
*/
public abstract class OrientationStrategy implements Runnable {

ScrollerHelper mHelperScroller;
final int mTouchSlop;

private final Position mPositionInfo;
private View mView;
private SwipeLayout.OnTranslateChangeListener mOnTranslateChangeListener;
final int mTouchSlop;
ScrollerHelper mHelperScroller;


public OrientationStrategy(View view) {
mView = view;
Expand Down Expand Up @@ -80,7 +81,7 @@ private int ensureInsideBounds(int x) {

boolean fling() {
int start = getDelta();
int end = calculateEnd(start);
int end = endPositionFrom(start);
boolean started = mHelperScroller.startScroll(start, end);
ViewCompat.postOnAnimation(mView, this);
return started;
Expand All @@ -98,7 +99,7 @@ public void run() {
}
}

private int calculateEnd(int currPosition) {
private int endPositionFrom(int currPosition) {
return mPositionInfo.closeTo(currPosition);
}

Expand Down

0 comments on commit bf6239c

Please sign in to comment.