diff --git a/library/src/main/java/com/lorentzos/flingswipe/FlingCardListener.java b/library/src/main/java/com/lorentzos/flingswipe/FlingCardListener.java index 5e15f10628..134379e193 100644 --- a/library/src/main/java/com/lorentzos/flingswipe/FlingCardListener.java +++ b/library/src/main/java/com/lorentzos/flingswipe/FlingCardListener.java @@ -32,6 +32,7 @@ public class FlingCardListener implements View.OnTouchListener { private final Object dataObject; private final float halfWidth; private float BASE_ROTATION_DEGREES; + private int ANIMATION_DURATION; private float aPosX; private float aPosY; @@ -52,10 +53,10 @@ public class FlingCardListener implements View.OnTouchListener { public FlingCardListener(View frame, Object itemAtPosition, FlingListener flingListener) { - this(frame, itemAtPosition, 15f, flingListener); + this(frame, itemAtPosition, 15f, 200, flingListener); } - public FlingCardListener(View frame, Object itemAtPosition, float rotation_degrees, FlingListener flingListener) { + public FlingCardListener(View frame, Object itemAtPosition, float rotation_degrees, int animationDuration, FlingListener flingListener) { super(); this.frame = frame; this.objectX = frame.getX(); @@ -67,6 +68,7 @@ public FlingCardListener(View frame, Object itemAtPosition, float rotation_degre this.parentWidth = ((ViewGroup) frame.getParent()).getWidth(); this.BASE_ROTATION_DEGREES = rotation_degrees; this.mFlingListener = flingListener; + this.ANIMATION_DURATION = animationDuration; } @@ -271,7 +273,7 @@ public void onAnimationEnd(Animator animation) { */ public void selectLeft() { if (!isAnimationRunning) - onSelected(true, objectY, 200); + onSelected(true, objectY, ANIMATION_DURATION); } /** @@ -279,7 +281,7 @@ public void selectLeft() { */ public void selectRight() { if (!isAnimationRunning) - onSelected(false, objectY, 200); + onSelected(false, objectY, ANIMATION_DURATION); } diff --git a/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java b/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java index 1defa04420..b42f231528 100644 --- a/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java +++ b/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java @@ -25,6 +25,7 @@ public class SwipeFlingAdapterView extends BaseFlingAdapterView { private int MAX_VISIBLE = 4; private int MIN_ADAPTER_STACK = 6; private float ROTATION_DEGREES = 15.f; + private int ANIMATION_DURATION = 200; private Adapter mAdapter; private int LAST_OBJECT_IN_STACK = 0; @@ -52,6 +53,7 @@ public SwipeFlingAdapterView(Context context, AttributeSet attrs, int defStyle) MAX_VISIBLE = a.getInt(R.styleable.SwipeFlingAdapterView_max_visible, MAX_VISIBLE); MIN_ADAPTER_STACK = a.getInt(R.styleable.SwipeFlingAdapterView_min_adapter_stack, MIN_ADAPTER_STACK); ROTATION_DEGREES = a.getFloat(R.styleable.SwipeFlingAdapterView_rotation_degrees, ROTATION_DEGREES); + ANIMATION_DURATION = a.getInt(R.styleable.SwipeFlingAdapterView_animation_duration, ANIMATION_DURATION); a.recycle(); } @@ -73,6 +75,12 @@ public void init(final Context context, Adapter mAdapter) { } setAdapter(mAdapter); } + + + public void setAnimationDuration(int animationDuration) + { + ANIMATION_DURATION = animationDuration; + } @Override public View getSelectedView() { @@ -214,8 +222,8 @@ private void setTopView() { mActiveCard = getChildAt(LAST_OBJECT_IN_STACK); if(mActiveCard!=null) { - flingCardListener = new FlingCardListener(mActiveCard, mAdapter.getItem(0), - ROTATION_DEGREES, new FlingCardListener.FlingListener() { + flingCardListener = new FlingCardListener(mActiveCard, mAdapter.getItem(0), ROTATION_DEGREES, + ANIMATION_DURATION, new FlingCardListener.FlingListener() { @Override public void onCardExited() { diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index 5bfd83361e..becb756b82 100644 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -6,6 +6,7 @@ + - \ No newline at end of file +