Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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;

}

Expand Down Expand Up @@ -271,15 +273,15 @@ public void onAnimationEnd(Animator animation) {
*/
public void selectLeft() {
if (!isAnimationRunning)
onSelected(true, objectY, 200);
onSelected(true, objectY, ANIMATION_DURATION);
}

/**
* Starts a default right exit animation.
*/
public void selectRight() {
if (!isAnimationRunning)
onSelected(false, objectY, 200);
onSelected(false, objectY, ANIMATION_DURATION);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand All @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<attr name="rotation_degrees" format="float"/>
<attr name="min_adapter_stack" format="integer"/>
<attr name="max_visible" format="integer"/>
<attr name="animation_duration" format="integer"/>
</declare-styleable>

</resources>
</resources>