Skip to content

Commit

Permalink
Merge pull request #25 from ppamorim/speed
Browse files Browse the repository at this point in the history
Added a method to scroll speed
  • Loading branch information
ppamorim committed May 25, 2015
2 parents e15d123 + 13444a5 commit d3d780e
Show file tree
Hide file tree
Showing 9 changed files with 1,558 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

public class ImageActivity extends AppCompatActivity {

private static final String CAN_ANIMATE = "can_animate";
public static final String DRAG_POSITION = "drag_position";

@InjectView(R.id.toolbar) Toolbar toolbar;
Expand All @@ -36,6 +37,14 @@ public class ImageActivity extends AppCompatActivity {
ButterKnife.inject(this);
configToolbar();
configIntents();
//if (savedInstanceState != null) {
// draggerView.setCanAnimate(savedInstanceState.getBoolean(CAN_ANIMATE));
//}
}

@Override protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(CAN_ANIMATE, draggerView.getCanAnimate());
}

@Override public boolean onOptionsItemSelected(MenuItem item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class ListActivity extends AbstractToolbarActivity {

@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
draggerView.setAnimationDuration(900, 500);
configRecyclerView();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ public void closeActivity() {
draggerPanel.closeActivity();
}

public void setAnimationDuration(int baseSettleDuration, int maxSettleDuration) {
draggerPanel.setAnimationDuration(baseSettleDuration, maxSettleDuration);
}

public void setAnimationDuration(int miliseconds, float multipler) {
draggerPanel.setAnimationDuration(miliseconds, multipler);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.github.ppamorim.dragger;

import android.support.v4.widget.ViewDragHelper;
import android.view.View;

public class DraggerHelperCallback extends ViewDragHelper.Callback {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,12 @@ public void closeActivity() {
draggerView.closeActivity();
}

public void setAnimationDuration(int baseSettleDuration, int maxSettleDuration) {
draggerView.setAnimationDuration(baseSettleDuration, maxSettleDuration);
}

public void setAnimationDuration(int miliseconds, float multipler) {
draggerView.setAnimationDuration(miliseconds, multipler);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import android.os.Handler;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.ViewDragHelper;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
Expand Down Expand Up @@ -157,6 +156,14 @@ public DraggerView(Context context, AttributeSet attrs, int defStyle) {
}
}

public void setCanAnimate(boolean canAnimate) {
animationFinish = !canAnimate;
}

public boolean getCanAnimate() {
return !animationFinish;
}

private float getVerticalDragRange() {
return verticalDragRange;
}
Expand Down Expand Up @@ -377,6 +384,16 @@ private void finish() {
}
}

public void setAnimationDuration(int baseSettleDuration, int maxSettleDuration) {
dragHelper.setBaseSettleDuration(baseSettleDuration);
dragHelper.setMaxSettleDuration(maxSettleDuration);
}

public void setAnimationDuration(int miliseconds, float multipler) {
dragHelper.setBaseSettleDuration(miliseconds);
dragHelper.setMaxSettleDuration((int) (miliseconds * multipler));
}

private DraggerHelperListener draggerListener = new DraggerHelperListener() {

@Override public void finishActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,12 @@ public void expand() {
lazyDraggerPanel.expand();
}

public void setAnimationDuration(int baseSettleDuration, int maxSettleDuration) {
lazyDraggerPanel.setAnimationDuration(baseSettleDuration, maxSettleDuration);
}

public void setAnimationDuration(int miliseconds, float multipler) {
lazyDraggerPanel.setAnimationDuration(miliseconds, multipler);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ public void expand() {
lazyDraggerView.expand();
}

public void setAnimationDuration(int baseSettleDuration, int maxSettleDuration) {
lazyDraggerView.setAnimationDuration(baseSettleDuration, maxSettleDuration);
}

public void setAnimationDuration(int miliseconds, float multipler) {
lazyDraggerView.setAnimationDuration(miliseconds, multipler);
}

}
Loading

0 comments on commit d3d780e

Please sign in to comment.