public void setItemImage(byte[] image) {
   try {
     Bitmap temp = Bitmap.createBitmapFromBytes(image, 0, image.length, 1);
     int w = TEXT_ANCHOR - 2 * PADDING_TOP;
     this.newsImage = Utils.resizedImage(temp, w, w);
   } catch (Exception e) {
   }
   synchronized (Application.getEventLock()) {
     NewsItemButton.super.invalidate();
   }
 }
  private void drawDummyPhoto(Graphics graphics) {
    graphics.setColor(0xcccccc);
    int w = TEXT_ANCHOR - 2 * PADDING_TOP;
    graphics.fillRoundRect(PADDING_LEFT, PADDING_TOP, w, w, 10, 10);

    graphics.setFont(Utils.getFont(5));
    graphics.setColor(0x999999);
    graphics.drawText(
        "NO PHOTO",
        (TEXT_ANCHOR - graphics.getFont().getAdvance("NO PHOTO")) / 2,
        (TEXT_ANCHOR - graphics.getFont().getHeight()) / 2);
  }
  protected void paint(Graphics g) {
    g.setColor(TITLE_COLOR);
    Font titleFont = Utils.getFontBold(FONT_SIZE);
    g.setFont(titleFont);

    int textWidht = Display.getWidth() - TEXT_ANCHOR - PADDING_RIGHT;

    if (title == null) {
      title = TextUtils.wrapText(newsItem.getTitle(), textWidht, titleFont);
    }
    int yOff = 0;
    for (int i = 0; i < title.size(); i++) {
      if (title.size() > 2 && i == 1) {
        g.drawText(
            title.elementAt(i).toString() + "...",
            TEXT_ANCHOR,
            PADDING_TOP + i * titleFont.getHeight());
        yOff += g.getFont().getHeight();
        break;
      } else {
        g.drawText(
            title.elementAt(i).toString(), TEXT_ANCHOR, PADDING_TOP + i * titleFont.getHeight());
        yOff += g.getFont().getHeight();
      }
    }

    Font textFont = Utils.getFont(FONT_SIZE);
    g.setColor(PRETEXT_COLOR);
    g.setFont(textFont);

    if (text == null) {
      text = TextUtils.wrapText(newsItem.getBody(), textWidht, textFont);
    }

    int titleHeight = PADDING_TOP + title.size() * titleFont.getHeight();
    int contentHeight = getPreferredHeight() - (PADDING_TOP);

    for (int i = 0; i < text.size(); i++) {
      if (yOff + g.getFont().getHeight() >= getPreferredHeight() - 2 * PADDING_TOP) {
        g.drawText(
            (String) text.elementAt(i) + "...",
            TEXT_ANCHOR,
            titleHeight + i * textFont.getHeight());
      } else {
        g.drawText((String) text.elementAt(i), TEXT_ANCHOR, titleHeight + i * textFont.getHeight());
      }

      yOff += g.getFont().getHeight();
      if (yOff >= getPreferredHeight() - 2 * PADDING_TOP) {
        break;
      }
    }

    if (newsImage != null) {
      try {
        g.drawBitmap(
            PADDING_LEFT,
            PADDING_TOP,
            newsImage.getWidth(),
            newsImage.getHeight(),
            newsImage,
            0,
            0);
      } catch (Exception e) {
        drawDummyPhoto(g);
      }
    } else {
      drawDummyPhoto(g);
    }
  }
 public NewsItemButton(NewsItem newsItem) {
   this.newsItem = newsItem;
   TEXT_ANCHOR = (Utils.getFont(7).getHeight() * 4 + PADDING_TOP * 2);
   setEditable(true);
 }