Shuffle extends FrameLayout { @Nullable static ViewHolder getNextUnusedViewHolder(List<ViewHolder> list, int position) { for (ViewHolder viewHolder : list) { if (viewHolder.position == -1 || viewHolder.position == position) { return viewHolder; } } return null; } Shuffle(Context context);  Shuffle(Context context, AttributeSet attrs);  Shuffle(Context context, AttributeSet attrs, int defStyleAttr); ShuffleSettings getShuffleSettings(); @Nullable Adapter getShuffleAdapter(); void setShuffleAdapter(@Nullable Adapter shuffleAdapter); void addListener(Listener listener); void removeListener(Listener listener); ShuffleViewAnimator getViewAnimator(); void setViewAnimator(ShuffleViewAnimator viewAnimator); void swipeRight(int duration); void swipeLeft(int duration); int getCurrentAdapterPosition(); CardDraggableView getDraggableView(int position); CardDraggableView getLastDraggableView(); CardDraggableView getFirstDraggableView(); void enable(boolean enable); void restartShuffling(); void revert(int duration);  }
@Test public void testGetNextUnusedViewHolder() throws Exception { List<Shuffle.ViewHolder> viewHolderList = Arrays.asList( mockShuffleViewHolder(1), mockShuffleViewHolder(-1), mockShuffleViewHolder(2) ); Shuffle.ViewHolder returnedHolder = Shuffle.getNextUnusedViewHolder(viewHolderList, 0); assertThat(returnedHolder.position).isEqualTo(-1); }
@Test public void testGetNextUnusedViewHolder_isNull() throws Exception { List<Shuffle.ViewHolder> viewHolderList = Arrays.asList( mockShuffleViewHolder(1), mockShuffleViewHolder(2), mockShuffleViewHolder(3) ); Shuffle.ViewHolder returnedHolder = Shuffle.getNextUnusedViewHolder(viewHolderList, 0); assertThat(returnedHolder).isNull(); }