@Override public View getView(int position, View convertView, ViewGroup parent) { Data_DB_News news = mNewsList.get(position); ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.item_news, parent, false); holder = new ViewHolder(); holder.Tv_NewsTitle = (TextView) convertView.findViewById(R.id.item_news_title); holder.Image = (SimpleDraweeView) convertView.findViewById(R.id.item_news_image); holder.Tv_PublishTime = (TextView) convertView.findViewById(R.id.time); holder.Tv_Advertise = (TextView) convertView.findViewById(R.id.advertise); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.Tv_NewsTitle.setText(news.getTitle()); Uri uri = Uri.parse(news.getTitleImg()); holder.Image.setImageURI(uri); if (news.getIsAdv() == Data_DB_News.TYPE_ADVERTISE) { holder.Tv_PublishTime.setVisibility(View.GONE); holder.Tv_Advertise.setVisibility(View.VISIBLE); } else { holder.Tv_PublishTime.setVisibility(View.VISIBLE); String[] timeArray = mDateFormat.format(news.getCreateTime()); StringBuilder publishTime = new StringBuilder(""); for (String s : timeArray) { publishTime.append(s + " "); } holder.Tv_PublishTime.setText(publishTime.toString()); holder.Tv_Advertise.setVisibility(View.GONE); } return convertView; }
@Override public void onBindViewHolder(ItineraryViewHolder holder, int position) { ItineraryInfo info = Itineraries.get(position); holder.Name.setText(info.Name); holder.Duration.setText(info.Duration); if (info.ImageUrl.isEmpty()) { holder.Image.setImageResource(R.drawable.placeholder); } else { Picasso.with(holder.Image.getContext()) .load(info.ImageUrl) .placeholder(R.drawable.placeholder) .error(R.drawable.placeholder) .into(holder.Image); } }