Back to project page VoxPopuli-Android.
The source code is released under:
GNU General Public License
If you think the Android project VoxPopuli-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package fr.kyriog.android.voxpopuli.adapter; /* w ww . j a v a2 s.co m*/ import java.util.List; import fr.kyriog.android.voxpopuli.R; import fr.kyriog.android.voxpopuli.entity.Player; import fr.kyriog.android.voxpopuli.handler.AvatarHandler; import fr.kyriog.android.voxpopuli.thread.AvatarDownloader; import android.app.Activity; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; public class PlayerAdapter extends BaseAdapter { protected final Activity activity; private final List<Player> players; public PlayerAdapter(Activity activity, List<Player> players) { this.activity = activity; this.players = players; } @Override public int getCount() { return players.size(); } @Override public Player getItem(int position) { return players.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null) convertView = activity.getLayoutInflater().inflate(R.layout.game_waiting_player, null); Player player = getItem(position); TextView username = (TextView) convertView.findViewById(R.id.game_waiting_player_username); username.setText(player.getUsername()); ImageView avatar = (ImageView) convertView.findViewById(R.id.game_waiting_player_image); if(player.getAvatarBitmap() == null) { avatar.setImageResource(R.drawable.default_avatar); AvatarDownloader downloader = new AvatarDownloader(new AvatarHandler(this), player); downloader.start(); } else avatar.setImageBitmap(player.getAvatarBitmap()); return convertView; } }