From d711b5f14f61eba597b3c6d017576d00dd64d5ab Mon Sep 17 00:00:00 2001 From: dwang999 Date: Fri, 10 Jul 2015 00:05:55 -0700 Subject: [PATCH 1/6] Added animation duration declareable --- library/src/main/res/values/attrs.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 + From 115580141e71f9afdd5ad4015c57f99e6a18a4cd Mon Sep 17 00:00:00 2001 From: dwang999 Date: Fri, 10 Jul 2015 00:10:01 -0700 Subject: [PATCH 2/6] Added animation duration variable --- .../com/lorentzos/flingswipe/FlingCardListener.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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); } From c4f06318f44a1a06a26e8a1c97672a5cefe11ec8 Mon Sep 17 00:00:00 2001 From: dwang999 Date: Fri, 10 Jul 2015 00:11:16 -0700 Subject: [PATCH 3/6] Added animation duration declareable --- .../com/lorentzos/flingswipe/SwipeFlingAdapterView.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java b/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java index 1defa04420..e731edfb9d 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(); } @@ -214,8 +216,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() { From 69f31c63694f63555aae92e8d8fc89a723412f30 Mon Sep 17 00:00:00 2001 From: dwang999 Date: Fri, 10 Jul 2015 00:28:05 -0700 Subject: [PATCH 4/6] changed to max visible --- .../java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java b/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java index e731edfb9d..8618a15082 100644 --- a/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java +++ b/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java @@ -123,7 +123,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto mInLayout = false; - if(adapterCount <= MIN_ADAPTER_STACK) mFlingListener.onAdapterAboutToEmpty(adapterCount); + if(adapterCount < MAX_VISIBLE) mFlingListener.onAdapterAboutToEmpty(adapterCount); } From 4781803102f1de180f2f1fa32cc67b06ec08e3e4 Mon Sep 17 00:00:00 2001 From: Derek Wang Date: Fri, 10 Jul 2015 00:57:52 -0700 Subject: [PATCH 5/6] Revert "changed to max visible" This reverts commit 69f31c63694f63555aae92e8d8fc89a723412f30. --- .../java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java b/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java index 8618a15082..e731edfb9d 100644 --- a/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java +++ b/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java @@ -123,7 +123,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto mInLayout = false; - if(adapterCount < MAX_VISIBLE) mFlingListener.onAdapterAboutToEmpty(adapterCount); + if(adapterCount <= MIN_ADAPTER_STACK) mFlingListener.onAdapterAboutToEmpty(adapterCount); } From e48d90b8830c4f5ce2728b0da538028f587435a1 Mon Sep 17 00:00:00 2001 From: dwang999 Date: Fri, 10 Jul 2015 01:27:55 -0700 Subject: [PATCH 6/6] Added way to change animation duration programatically --- .../com/lorentzos/flingswipe/SwipeFlingAdapterView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java b/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java index e731edfb9d..b42f231528 100644 --- a/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java +++ b/library/src/main/java/com/lorentzos/flingswipe/SwipeFlingAdapterView.java @@ -75,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() {