@Override
  protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
    super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);

    if (gainFocus) {
      setBackgroundColor(getResources().getColor(R.color.lb_default_brand_color));
      mActivity.setSelectedProgram(this);
    } else {
      setBackgroundColor(mBackgroundColor);
    }

    // TvApp.getApplication().getLogger().Debug("Focus on "+mProgram.getName()+ " was " +(gainFocus
    // ? "gained" : "lost"));
  }
  private void initComponent(LiveTvGuideActivity activity, ProgramInfoDto program) {
    mActivity = activity;
    mProgram = program;
    LayoutInflater inflater = LayoutInflater.from(activity);
    View v = inflater.inflate(R.layout.program_grid_cell, this, false);
    this.addView(v);

    mProgramName = (TextView) findViewById(R.id.programName);
    mInfoRow = (LinearLayout) findViewById(R.id.infoRow);
    mProgramName.setText(program.getName());
    mProgram = program;
    mProgramName.setFocusable(false);
    mInfoRow.setFocusable(false);
    mRecIndicator = (ImageView) findViewById(R.id.recIndicator);

    if (program.getIsMovie()) mBackgroundColor = getResources().getColor(R.color.guide_movie_bg);
    else if (program.getIsNews()) mBackgroundColor = getResources().getColor(R.color.guide_news_bg);
    else if (program.getIsSports())
      mBackgroundColor = getResources().getColor(R.color.guide_sports_bg);
    else if (program.getIsKids()) mBackgroundColor = getResources().getColor(R.color.guide_kids_bg);

    setBackgroundColor(mBackgroundColor);

    if (program.getStartDate() != null && program.getEndDate() != null) {
      TextView time = new TextView(activity);
      Date localStart = Utils.convertToLocalDate(program.getStartDate());
      if (localStart.getTime() + 60000 < activity.getCurrentLocalStartDate())
        mProgramName.setText("<< " + mProgramName.getText());
      time.setText(
          android.text.format.DateFormat.getTimeFormat(TvApp.getApplication())
                  .format(Utils.convertToLocalDate(program.getStartDate()))
              + "-"
              + android.text.format.DateFormat.getTimeFormat(TvApp.getApplication())
                  .format(Utils.convertToLocalDate(program.getEndDate())));
      mInfoRow.addView(time);
    }

    if (program.getOfficialRating() != null && !program.getOfficialRating().equals("0")) {
      InfoLayoutHelper.addSpacer(activity, mInfoRow, "  ", 10);
      InfoLayoutHelper.addBlockText(activity, mInfoRow, program.getOfficialRating(), 10);
    }

    if (program.getIsHD() != null && program.getIsHD()) {
      InfoLayoutHelper.addSpacer(activity, mInfoRow, "  ", 10);
      InfoLayoutHelper.addBlockText(activity, mInfoRow, "HD", 10);
    }

    if (program.getSeriesTimerId() != null) {
      mRecIndicator.setImageResource(R.drawable.recseries);
    } else if (program.getTimerId() != null) {
      mRecIndicator.setImageResource(R.drawable.rec);
    }

    setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            mActivity.showProgramOptions();
          }
        });
  }