Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add a card to the end of the hand without any specific information or animation
- public void add(CardView card) {
- rescale(SCALE_FACTOR, card);
- mHand.add(card); // mHand is a linkedList storing CardViews
- card.setIsInHand(true);
- mHandLayout.addView(card);
- card.setOnTouchListener(new CardInHandListener((RelativeLayout) mHandLayout.getParent(), this));
- mCardsInHand++;
- arrangeCards();
- card.flipCard();
- }
- // Dynamically resizes where the cards in the hand are placed.
- public void arrangeCards() {
- float prevCard = 0f; // The X value of the "previous card" is stored here
- for (CardView card : mHand) {
- if (card == mHand.peekFirst()) {
- card.setX((spaceAvailable() + mCardWidth) / 2); // Calculates the position for the first card
- card.setReturnPositionY(0f);
- } else {
- card.setX(prevCard + calcSpaceBetweenCards());
- }
- card.setReturnPositionX(card.getX());
- card.setReturnPositionY(mHand.peekFirst().getReturnPositionY());
- prevCard = card.getX();
- }
- angleCards();
- number = 0;
- for (CardView card : mHand) {
- card.setY(setVerticalDisplacement(card) + card.getReturnPositionY());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement