Android Open Source - VoxPopuli-Android Home Adapter






From Project

Back to project page VoxPopuli-Android.

License

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.

Java Source Code

package fr.kyriog.android.voxpopuli.adapter;
/*from w  w  w  .  j  av  a  2 s. c  o  m*/
import java.util.List;

import fr.kyriog.android.voxpopuli.HomeActivity;
import fr.kyriog.android.voxpopuli.R;
import fr.kyriog.android.voxpopuli.entity.Game;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

public class HomeAdapter extends BaseAdapter {
  private final HomeActivity activity;
  private final List<Game> games;

  public HomeAdapter(HomeActivity activity, List<Game> games) {
    this.activity = activity;
    this.games = games;
  }

  @Override
  public int getCount() {
    return games.size();
  }

  @Override
  public Game getItem(int position) {
    return games.get(position);
  }

  @Override
  public long getItemId(int position) {
    return position;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    final Game game = getItem(position);

    if(convertView == null)
      convertView = activity.getLayoutInflater().inflate(R.layout.home_game, null);

    Button gameId = (Button) convertView.findViewById(R.id.home_game_id);
    gameId.setText(game.getId());
    gameId.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        activity.launchGame(game);
      }
    });

    TextView gamemode = (TextView) convertView.findViewById(R.id.home_game_mode);
    gamemode.setText(game.getGamemode());

    TextView players = (TextView) convertView.findViewById(R.id.home_game_players);
    players.setText(activity.getResources().getString(R.string.home_game_players, game.getNbPlayers(), game.getNbMinPlayers()));

    return convertView;
  }

}




Java Source Code List

fr.kyriog.android.voxpopuli.GameActivity.java
fr.kyriog.android.voxpopuli.HomeActivity.java
fr.kyriog.android.voxpopuli.LoginActivity.java
fr.kyriog.android.voxpopuli.adapter.HomeAdapter.java
fr.kyriog.android.voxpopuli.adapter.PlayerAdapter.java
fr.kyriog.android.voxpopuli.adapter.ResultPlayerAdapter.java
fr.kyriog.android.voxpopuli.adapter.VotedPlayerAdapter.java
fr.kyriog.android.voxpopuli.entity.Game.java
fr.kyriog.android.voxpopuli.entity.Player.java
fr.kyriog.android.voxpopuli.entity.Question.java
fr.kyriog.android.voxpopuli.handler.AvatarHandler.java
fr.kyriog.android.voxpopuli.handler.GameHandler.java
fr.kyriog.android.voxpopuli.handler.HomeHandler.java
fr.kyriog.android.voxpopuli.socketio.BaseCallback.java
fr.kyriog.android.voxpopuli.socketio.GameCallback.java
fr.kyriog.android.voxpopuli.socketio.HomeCallback.java
fr.kyriog.android.voxpopuli.thread.AvatarDownloader.java