project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/TeamSelectionActivity.java
author Xeli
Sun, 21 Aug 2011 18:14:49 +0200
branchhedgeroid
changeset 5625 9add7b92c5f0
parent 5621 ea796c83ea47
child 5627 ce2d92589cbc
permissions -rw-r--r--
Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5621
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
     1
/*
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
     2
 * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
     3
 * Copyright (c) 2011 Richard Deurwaarder <xeli@xelification.com>
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
     4
 *
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
     8
 *
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    12
 * GNU General Public License for more details.
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    13
 *
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    14
 * You should have received a copy of the GNU General Public License
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    15
 * along with this program; if not, write to the Free Software
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    17
 */
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    18
ea796c83ea47 added licenses
Xeli
parents: 5603
diff changeset
    19
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    20
package org.hedgewars.mobile;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    21
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    22
import java.io.File;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    23
import java.util.ArrayList;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    24
import java.util.HashMap;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    25
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    26
import org.hedgewars.mobile.EngineProtocol.FrontendDataUtils;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    27
import org.hedgewars.mobile.EngineProtocol.Team;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    28
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    29
import android.app.Activity;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    30
import android.content.Intent;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    31
import android.os.Bundle;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    32
import android.os.Parcelable;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    33
import android.view.ContextMenu;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    34
import android.view.MenuItem;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    35
import android.view.View;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    36
import android.view.View.OnClickListener;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    37
import android.widget.AdapterView;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    38
import android.widget.AdapterView.AdapterContextMenuInfo;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    39
import android.widget.AdapterView.OnItemClickListener;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    40
import android.widget.ImageButton;
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    41
import android.widget.ImageView;
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    42
import android.widget.ListView;
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    43
import android.widget.RelativeLayout;
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    44
import android.widget.SimpleAdapter;
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    45
import android.widget.SimpleAdapter.ViewBinder;
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    46
import android.widget.TextView;
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    47
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    48
public class TeamSelectionActivity extends Activity{
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    49
5542
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
    50
	private static final int ACTIVITY_TEAMCREATION = 0;
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
    51
	
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    52
	private ImageButton addTeam, back;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    53
	private ListView availableTeams, selectedTeams;
5603
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
    54
	private ArrayList<HashMap<String, Object>> availableTeamsList, selectedTeamsList;
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    55
	private TextView txtInfo;
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    56
	private int minTeams = 2;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    57
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    58
	public void onCreate(Bundle savedInstanceState){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    59
		super.onCreate(savedInstanceState);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    60
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    61
		setContentView(R.layout.team_selector);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    62
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    63
		addTeam = (ImageButton) findViewById(R.id.btnAdd);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    64
		back = (ImageButton) findViewById(R.id.btnBack);
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    65
        txtInfo = (TextView) findViewById(R.id.txtInfo);
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    66
        
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    67
		addTeam.setOnClickListener(addTeamClicker);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    68
		back.setOnClickListener(backClicker);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    69
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    70
		availableTeams = (ListView) findViewById(R.id.availableTeams);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    71
		availableTeamsList = FrontendDataUtils.getTeams(this);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    72
		SimpleAdapter adapter = new SimpleAdapter(this, availableTeamsList, R.layout.team_selection_entry, new String[]{"txt", "img"}, new int[]{R.id.txtName, R.id.imgDifficulty});
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    73
		availableTeams.setAdapter(adapter);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    74
		registerForContextMenu(availableTeams);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    75
		availableTeams.setOnItemClickListener(availableClicker);
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    76
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    77
		selectedTeams = (ListView) findViewById(R.id.selectedTeams);
5603
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
    78
		selectedTeamsList = new ArrayList<HashMap<String, Object>>();
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    79
		ArrayList<HashMap<String, ?>> toBeRemoved = new ArrayList<HashMap<String, ?>>();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    80
		ArrayList<Team> teamsStartGame = getIntent().getParcelableArrayListExtra("teams");
5603
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
    81
		for(HashMap<String, Object> hashmap : availableTeamsList){
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    82
			for(Team t : teamsStartGame){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    83
				if(((Team)hashmap.get("team")).equals(t)){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    84
					toBeRemoved.add(hashmap);
5603
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
    85
					selectedTeamsList.add(FrontendDataUtils.teamToHashMap(t));//create a new hashmap to ensure all variables are entered into the map
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    86
				}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    87
			}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    88
		}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    89
		for(HashMap<String, ?> hashmap : toBeRemoved) availableTeamsList.remove(hashmap);
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    90
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    91
		adapter = new SimpleAdapter(this, selectedTeamsList, R.layout.team_selection_entry, new String[]{"txt", "img", "color", "count"}, new int[]{R.id.txtName, R.id.imgDifficulty, R.id.teamColor, R.id.teamCount});
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    92
		adapter.setViewBinder(viewBinder);
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    93
		selectedTeams.setAdapter(adapter);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
    94
		selectedTeams.setOnItemClickListener(selectedClicker);
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    95
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
    96
		txtInfo.setText(String.format(getResources().getString(R.string.teams_info_template), selectedTeams.getChildCount()));
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    97
	}
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    98
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
    99
	private ViewBinder viewBinder = new ViewBinder(){
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   100
		public boolean setViewValue(View view, Object data,	String textRepresentation) {
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   101
			switch(view.getId()){
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   102
			case R.id.teamColor:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   103
				setTeamColor(view, (Integer)data);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   104
				return true;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   105
			case R.id.teamCount:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   106
				setTeamHogCount((ImageView)view, (Integer)data);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   107
				return true;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   108
			default:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   109
				return false;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   110
			}
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   111
		}
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   112
	};
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   113
5542
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   114
	public void onActivityResult(int requestCode, int resultCode, Intent data){
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   115
		if(requestCode == ACTIVITY_TEAMCREATION){
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   116
			if(resultCode == Activity.RESULT_OK){
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   117
				updateListViews();
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   118
			}
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   119
		}else{
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   120
			super.onActivityResult(requestCode, resultCode, data);
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   121
		}
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   122
	}
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   123
	
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   124
	private void updateListViews(){
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   125
		unregisterForContextMenu(availableTeams);
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   126
		availableTeamsList = FrontendDataUtils.getTeams(this);
5603
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
   127
		ArrayList<HashMap<String, Object>> toBeRemoved = new ArrayList<HashMap<String, Object>>();
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
   128
		for(HashMap<String, Object> hashmap : selectedTeamsList){
5542
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   129
			String name = (String)hashmap.get("txt");
5603
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
   130
			
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
   131
			for(HashMap<String, Object> hash : availableTeamsList){
5542
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   132
				if(name.equals((String)hash.get("txt"))){
5603
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
   133
					toBeRemoved.add(hash);
5542
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   134
				}
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   135
			}
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   136
		}
5603
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
   137
		for(HashMap<String, Object> hash: toBeRemoved) availableTeamsList.remove(hash);
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
   138
		
5542
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   139
		SimpleAdapter adapter = new SimpleAdapter(this, availableTeamsList, R.layout.team_selection_entry, new String[]{"txt", "img"}, new int[]{R.id.txtName, R.id.imgDifficulty});
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   140
		availableTeams.setAdapter(adapter);
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   141
		registerForContextMenu(availableTeams);
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   142
		availableTeams.setOnItemClickListener(availableClicker);
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   143
		
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   144
		
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   145
	}
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   146
	
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   147
	private void setTeamColor(int position, int color){
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   148
		View iv = ((RelativeLayout)selectedTeams.getChildAt(position)).findViewById(R.id.teamCount);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   149
		setTeamColor(iv, color);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   150
	}
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   151
	private void setTeamColor(View iv, int color){
5532
3d7ac2b3b703 Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents: 5506
diff changeset
   152
		iv.setBackgroundColor(0xFF000000 + color);
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   153
	}
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   154
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   155
	private void setTeamHogCount(int position, int count){
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   156
		ImageView iv = (ImageView)((RelativeLayout)selectedTeams.getChildAt(position)).findViewById(R.id.teamCount);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   157
		setTeamHogCount(iv, count);
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   158
	}
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   159
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   160
	private void setTeamHogCount(ImageView iv, int count){
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   161
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   162
		switch(count){
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   163
		case 0:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   164
			iv.setImageResource(R.drawable.teamcount0);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   165
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   166
		case 1:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   167
			iv.setImageResource(R.drawable.teamcount1);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   168
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   169
		case 2:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   170
			iv.setImageResource(R.drawable.teamcount2);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   171
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   172
		case 3:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   173
			iv.setImageResource(R.drawable.teamcount3);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   174
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   175
		case 4:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   176
			iv.setImageResource(R.drawable.teamcount4);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   177
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   178
		case 5:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   179
			iv.setImageResource(R.drawable.teamcount5);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   180
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   181
		case 6:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   182
			iv.setImageResource(R.drawable.teamcount6);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   183
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   184
		case 7:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   185
			iv.setImageResource(R.drawable.teamcount7);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   186
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   187
		case 8:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   188
			iv.setImageResource(R.drawable.teamcount8);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   189
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   190
		case 9:
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   191
			iv.setImageResource(R.drawable.teamcount9);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   192
			break;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   193
		}
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   194
	}
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   195
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   196
	public void onBackPressed(){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   197
		returnTeams();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   198
		super.onBackPressed();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   199
	}
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   200
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   201
	private OnClickListener addTeamClicker = new OnClickListener(){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   202
		public void onClick(View v) {
5542
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   203
			startActivityForResult(new Intent(TeamSelectionActivity.this, TeamCreatorActivity.class), ACTIVITY_TEAMCREATION);
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   204
		}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   205
	};
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   206
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   207
	private OnClickListener backClicker = new OnClickListener(){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   208
		public void onClick(View v){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   209
			returnTeams();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   210
			finish();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   211
		}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   212
	};
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   213
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   214
	private OnItemClickListener availableClicker = new OnItemClickListener(){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   215
		public void onItemClick(AdapterView<?> arg0, View arg1, int position,long arg3) {
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   216
			selectAvailableTeamsItem(position);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   217
		}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   218
	};
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   219
	private OnItemClickListener selectedClicker = new OnItemClickListener(){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   220
		public void onItemClick(AdapterView<?> arg0, View arg1, int position,long arg3) {
5603
4e4a579a60af Fixed crash which occured when entering the teamselection menu for the second time
Xeli
parents: 5542
diff changeset
   221
			availableTeamsList.add((HashMap<String, Object>) selectedTeamsList.get(position));
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   222
			selectedTeamsList.remove(position);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   223
			((SimpleAdapter)availableTeams.getAdapter()).notifyDataSetChanged();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   224
			((SimpleAdapter)selectedTeams.getAdapter()).notifyDataSetChanged();
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   225
			
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   226
			txtInfo.setText(String.format(getResources().getString(R.string.teams_info_template), selectedTeamsList.size()));
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   227
		}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   228
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   229
	};
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   230
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   231
	public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuinfo){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   232
		menu.add(ContextMenu.NONE, 0, ContextMenu.NONE, R.string.select);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   233
		menu.add(ContextMenu.NONE, 2, ContextMenu.NONE, R.string.edit);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   234
		menu.add(ContextMenu.NONE, 1, ContextMenu.NONE, R.string.delete);
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   235
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   236
	}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   237
	public boolean onContextItemSelected(MenuItem item){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   238
		AdapterView.AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   239
		int position = menuInfo.position;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   240
		switch(item.getItemId()){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   241
		case 0://select
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   242
			selectAvailableTeamsItem(position);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   243
			return true;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   244
		case 1://delete
5532
3d7ac2b3b703 Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents: 5506
diff changeset
   245
			File f = new File(String.format("%s/%s/%s.xml", TeamSelectionActivity.this.getFilesDir(), Team.DIRECTORY_TEAMS, availableTeamsList.get(position).get("txt")));
3d7ac2b3b703 Fixed team colors in the UI, delete and a nullpointer bug when no teams are created
Xeli
parents: 5506
diff changeset
   246
			f.delete();
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   247
			availableTeamsList.remove(position);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   248
			((SimpleAdapter)availableTeams.getAdapter()).notifyDataSetChanged();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   249
			return true;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   250
		case 2://edit
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   251
			Intent i = new Intent(TeamSelectionActivity.this, TeamCreatorActivity.class);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   252
			Team t = (Team)availableTeamsList.get(position).get("team");
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   253
			i.putExtra("team", t);
5542
141c12a23787 start of implementation of the save button, check if there's something to save and update TeamSelectionActivity if a change has been made
Xeli
parents: 5532
diff changeset
   254
			startActivityForResult(i, ACTIVITY_TEAMCREATION);
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   255
			return true;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   256
		}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   257
		return false;
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   258
	}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   259
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   260
	private void selectAvailableTeamsItem(int position){
5506
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   261
		HashMap<String, Object> hash = (HashMap<String, Object>) availableTeamsList.get(position);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   262
		Team t = (Team)hash.get("team");
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   263
		int[] illegalcolors = new int[selectedTeamsList.size()];
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   264
		for(int i = 0; i < selectedTeamsList.size(); i++){
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   265
			illegalcolors[i] = ((Team)selectedTeamsList.get(i).get("team")).color;
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   266
		}
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   267
		t.setRandomColor(illegalcolors);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   268
		hash.put("color", t.color);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   269
		hash.put("count", t.hogCount);
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   270
		
2b0c4fcde4c6 Added color and team hog count
Xeli
parents: 5467
diff changeset
   271
		selectedTeamsList.add(hash);
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   272
		availableTeamsList.remove(position);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   273
		((SimpleAdapter)availableTeams.getAdapter()).notifyDataSetChanged();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   274
		((SimpleAdapter)selectedTeams.getAdapter()).notifyDataSetChanged();
5625
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   275
		
9add7b92c5f0 Added a check for team count to prevent the engine from crashes when starting with <2 teams + changed the text in the Teams selection menu
Xeli
parents: 5621
diff changeset
   276
		txtInfo.setText(String.format(getResources().getString(R.string.teams_info_template), selectedTeamsList.size()));
5467
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   277
	}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   278
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   279
	private void returnTeams(){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   280
		int teamsCount = selectedTeamsList.size();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   281
		if(teamsCount >= minTeams){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   282
			Intent i = new Intent();
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   283
			Parcelable[] teams = new Parcelable[teamsCount];
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   284
			for(int x = 0 ; x < teamsCount; x++){
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   285
				teams[x] = (Team)selectedTeamsList.get(x).get("team");
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   286
			}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   287
			i.putExtra("teams", teams);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   288
			setResult(Activity.RESULT_OK, i);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   289
		}else{
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   290
			setResult(Activity.RESULT_CANCELED);
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   291
		}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   292
	}
88e25840f532 Main activities for starting up the game, changing gameconfig, selecting and creating teams with their respective layouts and values
Xeli
parents:
diff changeset
   293
}