Пример #1
0
 public void setCards(List<CardInfo> cards) {
   listCardNames_ = cards;
   Bitmap cardBm;
   cardsInHand_.clear();
   for (CardInfo card : cards) {
     if ((cardHeight_ == 0) && (cardWidth_ == 0)) {
       cardBm = CardLoader.getInstance().getBitmap(getContext(), card.getName());
     } else {
       // Resize Bitmap
       cardBm =
           Bitmap.createScaledBitmap(
               CardLoader.getInstance().getBitmap(getContext(), card.getName()),
               (int) cardWidth_,
               (int) cardHeight_,
               false);
     }
     cardsInHand_.put(card, cardBm);
   }
 }
Пример #2
0
  @Override
  public void onDraw(Canvas canvas) {
    invalidate();

    // Calcul top, left
    int top = getHeight() / 6; // 40
    int left = 0;

    for (CardInfo card : listCardNames_) {
      canvas.drawBitmap(cardsInHand_.get(card), left, top, null);
      left += (int) cardWidth_;
    }
  }
Пример #3
0
 private int findSelectedCard(float x, float y) {
   for (int i = 0; i < cardsInHand_.size(); i++) {
     if ((i * cardWidth_ < x) && (x < (i + 1) * cardWidth_)) return i;
   }
   return -1;
 }