Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. // Add a card to the end of the hand without any specific information or animation
  2. public void add(CardView card) {
  3. rescale(SCALE_FACTOR, card);
  4. mHand.add(card); // mHand is a linkedList storing CardViews
  5. card.setIsInHand(true);
  6. mHandLayout.addView(card);
  7. card.setOnTouchListener(new CardInHandListener((RelativeLayout) mHandLayout.getParent(), this));
  8. mCardsInHand++;
  9. arrangeCards();
  10. card.flipCard();
  11. }
  12.  
  13. // Dynamically resizes where the cards in the hand are placed.
  14. public void arrangeCards() {
  15. float prevCard = 0f; // The X value of the "previous card" is stored here
  16. for (CardView card : mHand) {
  17. if (card == mHand.peekFirst()) {
  18. card.setX((spaceAvailable() + mCardWidth) / 2); // Calculates the position for the first card
  19. card.setReturnPositionY(0f);
  20. } else {
  21. card.setX(prevCard + calcSpaceBetweenCards());
  22. }
  23. card.setReturnPositionX(card.getX());
  24. card.setReturnPositionY(mHand.peekFirst().getReturnPositionY());
  25. prevCard = card.getX();
  26. }
  27. angleCards();
  28. number = 0;
  29. for (CardView card : mHand) {
  30. card.setY(setVerticalDisplacement(card) + card.getReturnPositionY());
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement