@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_horizontal_inline_without_rotation); ButterKnife.bind(this); shuffle.setShuffleAdapter(new TestAdapter()); shuffle.setViewAnimator(new ShuffleViewAnimator() .setPushLeftAnimateViewStackScaleUp(true) .setPushRightAnimateViewStackScaleUp(true) ); }
public void swipeRight(int duration) { if (viewAnimator != null && currentDraggableView != null) { viewAnimator.animateExit(currentDraggableView, Direction.RIGHT, duration); } }
@Override public void onDrag(DraggableView draggableView, float percentX, float percentY) { viewAnimator.updateViewsPositions(percentX, percentY); dispatchViewScrolledToListeners(draggableView, percentX, percentY); }
case TOP: if (pushTopAnimateViewStackScaleUp) { return animateViewStackScaleUp(direction, listener); } else { return animateViewStackGoBackBehind(direction, listener); return animateViewStackScaleUp(direction, listener); } else { return animateViewStackGoBackBehind(direction, listener); case LEFT: if (pushLeftAnimateViewStackScaleUp) { return animateViewStackScaleUp(direction, listener); } else { return animateViewStackGoBackBehind(direction, listener); return animateViewStackScaleUp(direction, listener); } else { return animateViewStackGoBackBehind(direction, listener);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_vertical); ButterKnife.bind(this); shuffle.setShuffleAdapter(new TestAdapter()); shuffle.setViewAnimator(new ShuffleViewAnimator() .setPushTopAnimateViewStackScaleUp(false) .setPushBottomAnimateViewStackScaleUp(false) ); }
private void initialize(Context context, AttributeSet attrs) { this.shuffleSettings = new ShuffleSettings(); this.shuffleSettings.handleAttributes(context, attrs); setViewAnimator(new ShuffleViewAnimator()); }
public void restartShuffling() { viewAnimator.animateRestartShuffling(new ShuffleViewAnimator.RestartListener() { @Override public void animationStarted() { } @Override public void animationMiddle() { try { adapterPosition = 0; updateAdapter(); } catch (Exception e) { e.printStackTrace(); } } @Override public void animationEnd() { } }); }
public void revert(int duration) { if (adapterPosition > 0) { moveLastCardToTop(); viewAnimator.animateRevert(duration, new ShuffleViewAnimator.RestartListener() { @Override public void animationStarted() { adapterPosition--; updateAdapter(); dispatchAdapterPositionToListeners(); } @Override public void animationMiddle() { } @Override public void animationEnd() { try { setFirstCardDraggable(); } catch (Exception e) { e.printStackTrace(); } } }); } }
@Override public void onDraggedEnded(final DraggableView draggableView, final Direction direction) { draggableView.setDraggable(false); moveFirstCardToStack(); viewAnimator.animateViewStackFrom(new ViewAnimator.Listener() { @Override public void animationStarted() { } @Override public void animationEnd() { dispatchExitedToListeners(draggableView, direction); setFirstCardDraggable(); } }, direction); }
public boolean animateRevert(int duration, @NonNull final RestartListener listener) { Direction lastExitDirection = getLastExitDirection(); if (lastExitDirection == null) { return false; switch (getLastExitDirection()) { case RIGHT: translationX = firstCard.getParentWidth();
setContentView(R.layout.activity_horizontal_inline); ButterKnife.bind(this); shuffle.setViewAnimator(new ShuffleViewAnimator() .setPushLeftAnimateViewStackScaleUp(false) .setPushRightAnimateViewStackScaleUp(false) ); shuffle.addListener(new Shuffle.Listener() {
public void swipeLeft(int duration) { if (viewAnimator != null && currentDraggableView != null) { viewAnimator.animateExit(currentDraggableView, Direction.LEFT, duration); } }
viewAnimator.updateViewsPositions(0, 0);
@Override public boolean animateExit(@NonNull CardDraggableView draggableView, Direction direction, int duration) { resetCard(shuffle.getDraggableView(1), duration); return super.animateExit(draggableView, direction, duration); }
@Test public void testSetFirstCardDraggable() throws Exception { //Given CardDraggableView draggableView1 = mockDraggableView(); CardDraggableView draggableView2 = mockDraggableView(); CardDraggableView draggableView3 = mockDraggableView(); shuffle.draggableViews.addAll(Arrays.asList(draggableView1, draggableView2, draggableView3)); //When shuffle.setFirstCardDraggable(); //Then verify(draggableView1).setDraggable(eq(true)); verify(draggableView1).reset(); verify(draggableView1).setDragListener(any(DraggableView.DraggableViewListener.class)); verify(viewAnimator).updateViewsPositions(eq(0.0f), eq(0.0f)); }
@Test public void testSwipeLeft() throws Exception { //Given shuffle.currentDraggableView = mock(CardDraggableView.class); //When shuffle.swipeLeft(1000); //Then verify(viewAnimator).animateExit(any(CardDraggableView.class), eq(Direction.LEFT), eq(1000)); }
@Test public void testSwipeRight() throws Exception { //Given shuffle.currentDraggableView = mock(CardDraggableView.class); //When shuffle.swipeRight(1000); //Then verify(viewAnimator).animateExit(any(CardDraggableView.class), eq(Direction.RIGHT), eq(1000)); }