@Override public View getHeaderView(int position, View convertView, ViewGroup parent) { ShowInfo showInfo = this.getItem(position); HeaderViewHolder holder = null; if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.show_list_header, null, false); holder = new HeaderViewHolder(); holder.tvShowListHeader = (TextView) convertView.findViewById(R.id.tvShowListHeader); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); } holder.tvShowListHeader.setText(showInfo.getSchedule().toString()); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ShowInfo showInfo = this.getItem(position); ItemViewHolder holder = null; if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.show_item, null, false); holder = new ItemViewHolder(); holder.tvShowName = (TextView) convertView.findViewById(R.id.tvShowName); holder.tvEpisodeTitle = (TextView) convertView.findViewById(R.id.tvEpisodeTitle); holder.tvEpisodeDate = (TextView) convertView.findViewById(R.id.tvEpisodeDate); holder.tvEpisodeTime = (TextView) convertView.findViewById(R.id.tvEpisodeTime); holder.tvShowImage = (SmartImageView) convertView.findViewById(R.id.tvShowImage); convertView.setTag(holder); } else { holder = (ItemViewHolder) convertView.getTag(); holder.tvShowImage.setImageResource(android.R.color.transparent); } holder.tvShowName.setText(showInfo.getName()); holder.tvEpisodeTitle.setText(showInfo.getNextEpisodeTitle()); holder.tvEpisodeDate.setText(showInfo.getNextEpisodeDateAsLabel()); String showImage = showInfo.getImage(); if (showImage == null || showImage.length() == 0) { holder.tvShowImage.setImageResource(R.drawable.ic_tv); } else { holder.tvShowImage.setImageUrl(showImage); } Schedule schedule = showInfo.getSchedule(); if (schedule == Schedule.TBD) { holder.tvEpisodeTime.setText("TBA"); } else if (schedule == Schedule.TODAY) { holder.tvEpisodeTime.setText(showInfo.getNextEpisodeTimeAsLabel() + " TODAY"); } else if (schedule == Schedule.TOMORROW) { holder.tvEpisodeTime.setText(showInfo.getNextEpisodeTimeAsLabel() + " TOMORROW"); } else { holder.tvEpisodeTime.setText(showInfo.getNextEpisodeDaysLeft() + " DAYS"); } return convertView; }