@Override public void showWords(List<FlashcardWord> wordList) { viewFlipper.setDisplayedChild(CARDS); new Handler() .post( () -> { revealedCards.clear(); swipeDeck.setAdapterIndex(0); adapter.setData(wordList); }); buttonContainer.setVisibility(View.GONE); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flashcards); ButterKnife.bind(this); if (savedInstanceState == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { rootLayout.setVisibility(View.INVISIBLE); cx = getIntent().getIntExtra(REVEAL_X, 0); cy = getIntent().getIntExtra(REVEAL_Y, 0); ViewTreeObserver viewTreeObserver = rootLayout.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { circularRevealActivity(rootLayout, cx, cy, true); rootLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); } } adapter = new SwipeDeckAdapter( new FlashcardView.IFlashcardListener() { @Override public void onRightClick() { swipeDeck.swipeTopCardRight(500); } @Override public void onWrongClick() { swipeDeck.swipeTopCardLeft(500); } @Override public void onRevealed() { revealedCards.put((int) swipeDeck.getTopCardItemId(), true); } }); swipeDeck.setAdapter(adapter); swipeDeck.setCallback( new SwipeDeck.SwipeDeckCallback() { @Override public void cardSwipedLeft(long positionInAdapter) { FlashcardWord word = adapter.getItem((int) positionInAdapter); getPresenter().onWordWrong(word); if (positionInAdapter == adapter.getCount() - 1) { getPresenter().onCardsDepleted(); } } @Override public void cardSwipedRight(long positionInAdapter) { FlashcardWord word = adapter.getItem((int) positionInAdapter); getPresenter().onWordRight(word); if (positionInAdapter == adapter.getCount() - 1) { getPresenter().onCardsDepleted(); } } @Override public boolean isDragEnabled(long itemId) { return revealedCards.get((int) itemId); } // @Override // public void cardsDepleted() { // getPresenter().onCardsDepleted(); // } // // }); resultErrorList.setLayoutManager( new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); }