Android Open Source - PowerGridCompanion Player Order Adapter






From Project

Back to project page PowerGridCompanion.

License

The source code is released under:

Apache License

If you think the Android project PowerGridCompanion 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 com.mintcode.kris.powergridhelper.Adapters;
/*from  ww  w. jav a 2 s .c  o m*/
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.mintcode.kris.powergridhelper.Models.Player;
import com.mintcode.kris.powergridhelper.R;

import java.util.ArrayList;
import java.util.Collections;

/**
 * Created by kris on 6/29/14.
 */
public class PlayerOrderAdapter extends ArrayAdapter<Player> {


    Context mContext;
    ArrayList<Player> list;

    public PlayerOrderAdapter(Context context,int resource, ArrayList<Player> l) {
        //super(context, l.size());
        super(context,resource,l);
        mContext = context;
        list = l;
    }


    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        View view = convertView;
        if (view == null) {
            view = LayoutInflater.from(mContext).inflate(R.layout.sample_player_view, parent, false);
        }

        TextView name = (TextView) view.findViewById(R.id.EditPlayerName);
        ImageView color = (ImageView) view.findViewById(R.id.PlayerColor);
        TextView money = (TextView) view.findViewById(R.id.MoneySummary);
        TextView building = (TextView) view.findViewById(R.id.BuildingSummary);
        TextView power = (TextView) view.findViewById(R.id.PowerSummary);
        LinearLayout resources = (LinearLayout) view.findViewById(R.id.ResourceSummary);

        name.setText(list.get(position).getName());
        color.setBackgroundColor(list.get(position).getColor());
        money.setText("$"+list.get(position).getMoney());
        money.setVisibility(View.VISIBLE);
        building.setText(list.get(position).getLargest_power_plant()+"");
        building.setVisibility(View.VISIBLE);
        power.setText(list.get(position).getCities_owned()+"");
        power.setVisibility(View.VISIBLE);
        resources.setVisibility(View.VISIBLE);
        ((TextView)resources.findViewById(R.id.CoalValue)).setText(list.get(position).getCoal()+"");
        ((TextView)resources.findViewById(R.id.OilValue)).setText(list.get(position).getOil()+"");
        ((TextView)resources.findViewById(R.id.GarbageValue)).setText(list.get(position).getGarbage()+"");
        ((TextView)resources.findViewById(R.id.UraniumValue)).setText(list.get(position).getUranium()+"");

        ((LinearLayout)view.findViewById(R.id.SummaryDescriptions)).setVisibility(View.VISIBLE);

        return view;
    }


}




Java Source Code List

com.mintcode.kris.powergridhelper.Activities.BuildingActivity.java
com.mintcode.kris.powergridhelper.Activities.PlayerSelection.java
com.mintcode.kris.powergridhelper.Activities.PlayerSetup.java
com.mintcode.kris.powergridhelper.Activities.PowerPlantAuctionActivity.java
com.mintcode.kris.powergridhelper.Activities.ResourcePurchaseActivity.java
com.mintcode.kris.powergridhelper.Activities.StartScreen.java
com.mintcode.kris.powergridhelper.Activities.TurnOrderSummary.java
com.mintcode.kris.powergridhelper.Adapters.BuildingAdapter.java
com.mintcode.kris.powergridhelper.Adapters.PlayerOrderAdapter.java
com.mintcode.kris.powergridhelper.Adapters.PlayerSetupAdapter.java
com.mintcode.kris.powergridhelper.Adapters.PowerPlantAdapter.java
com.mintcode.kris.powergridhelper.Adapters.ResourceAdapter.java
com.mintcode.kris.powergridhelper.Models.Player.java