Example #1
0
  public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
    if (isMoreButton(index)) {
      Font bold = Font.getDefault().derive(Font.BOLD);
      g.setFont(bold);
      String strMore = "More";
      int xx = (width - bold.getAdvance(strMore)) / 2;
      int yy = y + (ScheduleScreen.LIST_HEIGHT - bold.getHeight()) / 2;
      if (listField.getSelectedIndex() == index) {
        g.setColor(0);
        g.drawText(strMore, xx + 1, yy + 1);
        g.setColor(0xffffff);
        g.drawText(strMore, xx, yy);
      } else {
        g.setColor(0);
        g.drawText(strMore, xx, yy);
      }
      return;
    }
    ProgramData data = (ProgramData) listData.elementAt(index);
    //		if(!listField.isFocus() || index!=listField.getSelectedIndex()){
    //			for(int x=0; x<Display.getWidth(); x+= ScheduleScreen.LIST_BACKGROUND.getWidth())
    //				g.drawBitmap(x, y, ScheduleScreen.LIST_BACKGROUND.getWidth(),
    // ScheduleScreen.LIST_BACKGROUND.getHeight(), ScheduleScreen.LIST_BACKGROUND, 0, 0);
    //		}
    if (!listField.isFocus() || index != listField.getSelectedIndex()) {
      for (int x = 0; x < Display.getWidth(); x += ScheduleScreen.LIST_BACKGROUND.getWidth())
        g.drawBitmap(
            x,
            y,
            ScheduleScreen.LIST_BACKGROUND.getWidth(),
            ScheduleScreen.LIST_BACKGROUND.getHeight(),
            ScheduleScreen.LIST_BACKGROUND,
            0,
            0);
    }
    Bitmap thumb = TVApi.getChannelThumbnail(data.channelId);
    if (thumb != null) {
      int padding = (ScheduleScreen.LIST_HEIGHT - thumb.getHeight()) / 2;
      int ty = y + padding;
      int tx = padding;
      g.drawBitmap(tx, ty, thumb.getWidth(), thumb.getHeight(), thumb, 0, 0);
      g.setColor(0);
      g.drawText(data.beginTime + " - " + data.endTime, tx + thumb.getWidth() + tx, ty);
      Bitmap favorite =
          data.isFavorite ? ScheduleScreen.LIST_FAVORITE_ON : ScheduleScreen.LIST_FAVORITE_OFF;
      int titleMaxWidth = width - thumb.getWidth() - favorite.getWidth() - (padding * 4);
      g.drawText(
          data.title,
          tx + thumb.getWidth() + tx,
          ty + thumb.getHeight(),
          DrawStyle.BASELINE | DrawStyle.ELLIPSIS,
          titleMaxWidth);

      g.drawBitmap(
          width - padding - favorite.getWidth(),
          y + (ScheduleScreen.LIST_HEIGHT - favorite.getHeight()) / 2,
          favorite.getWidth(),
          favorite.getHeight(),
          favorite,
          0,
          0);
    }
  }