@Override
 public long getHeaderId(int position) {
   // return the first character of the country as ID because this is what headers are based upon
   if (scheduleData != null) {
     AllEpisodesResponse episode = scheduleData.get(position);
     if (episode != null) {
       String day = episode.getDay();
       if (day != null && day.length() > 0) {
         try {
           if (day.equalsIgnoreCase(mContext.getResources().getString(R.string.monday))) {
             return 0;
           } else if (day.equalsIgnoreCase(mContext.getResources().getString(R.string.tuesday))) {
             return 1;
           } else if (day.equalsIgnoreCase(
               mContext.getResources().getString(R.string.wednesday))) {
             return 2;
           } else if (day.equalsIgnoreCase(mContext.getResources().getString(R.string.thursday))) {
             return 3;
           } else if (day.equalsIgnoreCase(mContext.getResources().getString(R.string.friday))) {
             return 4;
           } else if (day.equalsIgnoreCase(mContext.getResources().getString(R.string.saturday))) {
             return 5;
           } else if (day.equalsIgnoreCase(mContext.getResources().getString(R.string.sunday))) {
             return 6;
           } else {
             return 7;
           }
         } catch (Exception e) {
           return 7;
         }
       }
     }
   }
   return 7;
 }
  @Override
  public View getHeaderView(int position, View convertView, ViewGroup parent) {
    HeaderViewHolder holder;
    if (convertView == null) {
      holder = new HeaderViewHolder();
      convertView = inflater.inflate(R.layout.header, parent, false);
      holder.text = (TextView) convertView.findViewById(R.id.text);
      convertView.setTag(holder);
    } else {
      holder = (HeaderViewHolder) convertView.getTag();
    }
    // set header text as first char in name
    AllEpisodesResponse episode = getItem(position);
    String airDate = episode.getAirdate();
    String monthNumber = getMonthNumber(airDate);
    String day = getDay(airDate);
    String headerTextDate = null;
    if (monthNumber != null && day != null) {
      String monthName = getMonthName(monthNumber);
      if (monthName != null) {
        headerTextDate = monthName + " " + day;
      }
    }

    String headerText = null;
    if (headerTextDate != null && headerTextDate.length() > 0) {
      headerText = scheduleData.get(position).getDay() + ", " + headerTextDate;
    } else {
      headerText = scheduleData.get(position).getDay();
    }
    holder.text.setText(headerText);
    return convertView;
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    if (convertView == null) {
      convertView =
          ((AppCompatActivity) mContext)
              .getLayoutInflater()
              .inflate(layoutResourceId, parent, false);
      holder = new ViewHolder();
      holder.rowTextContainer = (RelativeLayout) convertView.findViewById(R.id.rowTextContainer);
      holder.dateContainer = (RelativeLayout) convertView.findViewById(R.id.dateContainer);
      holder.tvHour = (TextView) convertView.findViewById(R.id.tvHour);
      holder.tvChannel = (TextView) convertView.findViewById(R.id.tvChannel);
      holder.tvShowName = (TextView) convertView.findViewById(R.id.tvShowName);
      holder.infoContainer = (RelativeLayout) convertView.findViewById(R.id.infoContainer);
      holder.tvSeasonEpisode = (TextView) convertView.findViewById(R.id.tvSeasonEpisode);
      holder.tvEpisodeName = (TextView) convertView.findViewById(R.id.tvEpisodeName);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    final AllEpisodesResponse episode = getItem(position);
    if (episode != null) {
      final String episodeName = episode.getName();
      Integer season = episode.getSeason();
      Integer number = episode.getNumber();
      String airDate = episode.getAirdate();
      Calendar today = Calendar.getInstance();

      int cYear = today.get(Calendar.YEAR);
      int cMonth = today.get(Calendar.MONTH) + 1;
      int cDay = today.get(Calendar.DAY_OF_MONTH);

      if (season != null && number != null) {
        holder.tvSeasonEpisode.setText("Season " + season + ", Episode " + number);
      } else {
        holder.tvSeasonEpisode.setText("");
      }
      if (episodeName != null) {
        holder.tvEpisodeName.setText(episodeName);
      }

      String airTime = episode.getAirtime();
      String channelName = episode.getChannelName();
      if (airTime != null && channelName != null) {
        holder.tvHour.setVisibility(View.VISIBLE);
        holder.tvChannel.setVisibility(View.VISIBLE);
        holder.tvHour.setText(airTime);
        holder.tvChannel.setText(channelName);
      } else {
        holder.tvHour.setVisibility(View.INVISIBLE);
        holder.tvChannel.setVisibility(View.INVISIBLE);
        holder.tvHour.setText("     ");
        holder.tvChannel.setText(" ");
      }

      String showName = episode.getShowName();
      if (showName != null) {
        holder.tvShowName.setVisibility(View.VISIBLE);
        holder.tvShowName.setText(showName);
      } else {
        holder.tvShowName.setVisibility(View.GONE);
      }
    }
    return convertView;
  }