
net.stepniak.android.picheese.adapter.PhotosGridAdapter Maven / Gradle / Ivy
The newest version!
package net.stepniak.android.picheese.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import net.stepniak.android.picheese.R;
import net.stepniak.android.picheese.adapter.PhotosBaseAdapter;
import net.stepniak.picheese.pojos.v1.CollectionPhoto;
import net.stepniak.picheese.pojos.v1.Photo;
public class PhotosGridAdapter extends PhotosBaseAdapter {
private LayoutInflater mInflater;
public PhotosGridAdapter(Context c, CollectionPhoto collectionPhoto) {
super(c, collectionPhoto);
mInflater = LayoutInflater.from(c);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(getItemLayoutId(), null);
holder = new ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.title);
holder.thumbnail = (ImageView) convertView.findViewById(R.id.thumbnail);
holder.views = (TextView) convertView.findViewById(R.id.views);
holder.likes = (TextView) convertView.findViewById(R.id.likes);
holder.favs = (TextView) convertView.findViewById(R.id.favs);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
//TODO temp hack
if (position >= getCount()) {
position = 0;
}
Photo photo = getItem(position);
if (photo != null) {
// VideoInfo videoInfo = link.getVideoInfo();
// holder.title.setText(videoInfo.getTitle());
holder.likes.setText(String.valueOf(photo.getRating().getScore()));
// holder.favs.setText(String.valueOf(photo.getLikes()));
mImageDownloader.download(photo.getUrl().getThumbnail(), holder.thumbnail);
}
//TODO else?!
return convertView;
}
static class ViewHolder {
TextView title;
ImageView thumbnail;
TextView views;
TextView likes;
TextView favs;
}
@Override
protected int getItemLayoutId() {
return R.layout.link_grid_view;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy