Skip to content

Instantly share code, notes, and snippets.

@Rexee
Last active April 25, 2016 15:44
Show Gist options
  • Save Rexee/dc3b3ada1cb07436aff3 to your computer and use it in GitHub Desktop.
Save Rexee/dc3b3ada1cb07436aff3 to your computer and use it in GitHub Desktop.
BaseAdapter
public class RankedMostPlayedAdapter extends BaseAdapter {
private LayoutInflater mInflater;
private List<StatsRanked> mStatsRanked;
private AQuery aq;
public RankedMostPlayedAdapter(Context context, List<StatsRanked> mStatsRanked) {
this.mStatsRanked = mStatsRanked;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
aq = new AQuery(context);
}
static class ViewHolder {
public ImageView championIcon;
public TextView championName;
public TextView championGamesPlayed;
}
@Override
public int getCount() {
return mStatsRanked.size();
}
@Override
public Object getItem(int position) {
return mStatsRanked.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
View v = convertView;
if (v == null) {
v = mInflater.inflate(R.layout.most_played_item, parent, false);
holder = new ViewHolder();
holder.championIcon = (ImageView) v.findViewById(R.id.championIcon);
holder.championName = (TextView) v.findViewById(R.id.championName);
holder.championGamesPlayed = (TextView) v.findViewById(R.id.championGamesPlayed);
v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}
StatsRanked currentStats = mStatsRanked.get(position);
aq.id(holder.championIcon).image(API.imgChampionStaticCDN(currentStats.championId));
aq.id(holder.championName).text("" + currentStats.championId);
aq.id(holder.championGamesPlayed).text("" + currentStats.totalSessionsPlayed);
return v;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment