project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java
author nemo
Tue, 21 Aug 2012 19:40:02 -0400
changeset 7567 da2aa8355d91
parent 6727 b3160a49f02e
child 6842 2e6391f33204
permissions -rw-r--r--
allow lua to specify template by number
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
     1
/*
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
     2
 * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
6700
e04da46ee43c the most important commit of the year
koda
parents: 6567
diff changeset
     3
 * Copyright (c) 2011-2012 Richard Deurwaarder <xeli@xelification.com>
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
     4
 *
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
     8
 *
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    12
 * GNU General Public License for more details.
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    13
 *
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    17
 */
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    18
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    19
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    20
package org.hedgewars.hedgeroid;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    21
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    22
import java.io.File;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    23
import java.io.FileNotFoundException;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    24
import java.io.FileOutputStream;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    25
import java.io.IOException;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    26
import java.util.ArrayList;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    27
import java.util.HashMap;
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
    28
import java.util.List;
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    29
6488
c356ddebab84 android: moved the different objects representing the different game parameters to a different package
Xeli
parents: 6448
diff changeset
    30
import org.hedgewars.hedgeroid.Datastructures.FrontendDataUtils;
c356ddebab84 android: moved the different objects representing the different game parameters to a different package
Xeli
parents: 6448
diff changeset
    31
import org.hedgewars.hedgeroid.Datastructures.Team;
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    32
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    33
import android.app.Activity;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    34
import android.graphics.Bitmap;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    35
import android.graphics.drawable.Drawable;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    36
import android.media.MediaPlayer;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    37
import android.os.Bundle;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    38
import android.view.View;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    39
import android.view.View.OnClickListener;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    40
import android.view.View.OnFocusChangeListener;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    41
import android.widget.AdapterView;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    42
import android.widget.AdapterView.OnItemSelectedListener;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    43
import android.widget.ArrayAdapter;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    44
import android.widget.EditText;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    45
import android.widget.ImageButton;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    46
import android.widget.ImageView;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    47
import android.widget.LinearLayout;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    48
import android.widget.RelativeLayout;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    49
import android.widget.ScrollView;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    50
import android.widget.SimpleAdapter;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    51
import android.widget.Spinner;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    52
import android.widget.TextView;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    53
import android.widget.Toast;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    54
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
    55
public class TeamCreatorActivity extends Activity implements Runnable{
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    56
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    57
	private TextView name;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    58
	private Spinner difficulty, grave, flag, voice, fort;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    59
	private ImageView imgFort;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    60
	private ArrayList<ImageButton> hogDice = new ArrayList<ImageButton>();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    61
	private ArrayList<Spinner> hogHat = new ArrayList<Spinner>();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    62
	private ArrayList<EditText> hogName = new ArrayList<EditText>();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    63
	private ImageButton back, save, voiceButton;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    64
	private ScrollView scroller;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    65
	private MediaPlayer mp = null;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    66
	private boolean settingsChanged = false;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    67
	private boolean saved = false;
6432
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
    68
	private String fileName = null;
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    69
6567
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
    70
	private final List<HashMap<String, ?>> flagsData = new ArrayList<HashMap<String, ?>>();
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
    71
	private final List<HashMap<String, ?>> typesData = new ArrayList<HashMap<String, ?>>();
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
    72
	private final List<HashMap<String, ?>> gravesData = new ArrayList<HashMap<String, ?>>();
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
    73
	private final List<HashMap<String, ?>> hatsData = new ArrayList<HashMap<String, ?>>();
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
    74
	private final List<String> voicesData = new ArrayList<String>();
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
    75
	private final List<String> fortsData = new ArrayList<String>();
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
    76
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    77
	public void onCreate(Bundle savedInstanceState) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    78
		super.onCreate(savedInstanceState);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    79
		setContentView(R.layout.team_creation);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    80
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    81
		name = (TextView) findViewById(R.id.txtName);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    82
		difficulty = (Spinner) findViewById(R.id.spinType);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    83
		grave = (Spinner) findViewById(R.id.spinGrave);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    84
		flag = (Spinner) findViewById(R.id.spinFlag);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    85
		voice = (Spinner) findViewById(R.id.spinVoice);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    86
		fort = (Spinner) findViewById(R.id.spinFort);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    87
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    88
		imgFort = (ImageView) findViewById(R.id.imgFort);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    89
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    90
		back = (ImageButton) findViewById(R.id.btnBack);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    91
		save = (ImageButton) findViewById(R.id.btnSave);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    92
		voiceButton = (ImageButton) findViewById(R.id.btnPlay);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    93
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    94
		scroller = (ScrollView) findViewById(R.id.scroller);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    95
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    96
		save.setOnClickListener(saveClicker);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    97
		back.setOnClickListener(backClicker);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    98
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
    99
		LinearLayout ll = (LinearLayout) findViewById(R.id.HogsContainer);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   100
		for (int i = 0; i < ll.getChildCount(); i++) {
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   101
			RelativeLayout team_creation_entry = (RelativeLayout) ll.getChildAt(i);
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   102
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   103
			hogHat.add((Spinner) team_creation_entry
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   104
					.findViewById(R.id.spinTeam1));
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   105
			hogDice.add((ImageButton) team_creation_entry
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   106
					.findViewById(R.id.btnTeam1));
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   107
			hogName.add((EditText) team_creation_entry
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   108
					.findViewById(R.id.txtTeam1));
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   109
		}
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   110
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   111
		SimpleAdapter sa = new SimpleAdapter(this, gravesData,
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   112
				R.layout.spinner_textimg_entry, new String[] { "txt", "img" },
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   113
				new int[] { R.id.spinner_txt, R.id.spinner_img });
6350
41b0a9955c47 new download manager \o/
Xeli
parents: 6049
diff changeset
   114
		sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry);
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   115
		sa.setViewBinder(viewBinder);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   116
		grave.setAdapter(sa);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   117
		grave.setOnFocusChangeListener(focusser);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   118
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   119
		sa = new SimpleAdapter(this, flagsData, R.layout.spinner_textimg_entry,
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   120
				new String[] { "txt", "img" }, new int[] { R.id.spinner_txt,
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   121
				R.id.spinner_img });
6350
41b0a9955c47 new download manager \o/
Xeli
parents: 6049
diff changeset
   122
		sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry);
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   123
		sa.setViewBinder(viewBinder);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   124
		flag.setAdapter(sa);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   125
		flag.setOnFocusChangeListener(focusser);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   126
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   127
		sa = new SimpleAdapter(this, typesData, R.layout.spinner_textimg_entry,
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   128
				new String[] { "txt", "img" }, new int[] { R.id.spinner_txt,
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   129
				R.id.spinner_img });
6350
41b0a9955c47 new download manager \o/
Xeli
parents: 6049
diff changeset
   130
		sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry);
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   131
		difficulty.setAdapter(sa);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   132
		difficulty.setOnFocusChangeListener(focusser);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   133
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   134
		sa = new SimpleAdapter(this, hatsData, R.layout.spinner_textimg_entry,
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   135
				new String[] { "txt", "img" }, new int[] { R.id.spinner_txt,
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   136
				R.id.spinner_img });
6350
41b0a9955c47 new download manager \o/
Xeli
parents: 6049
diff changeset
   137
		sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry);
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   138
		sa.setViewBinder(viewBinder);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   139
		for (Spinner spin : hogHat) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   140
			spin.setAdapter(sa);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   141
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   142
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   143
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.listview_item, voicesData);
6350
41b0a9955c47 new download manager \o/
Xeli
parents: 6049
diff changeset
   144
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   145
		voice.setAdapter(adapter);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   146
		voice.setOnFocusChangeListener(focusser);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   147
		voiceButton.setOnClickListener(voiceClicker);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   148
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   149
		adapter = new ArrayAdapter<String>(this, R.layout.listview_item, fortsData);
6350
41b0a9955c47 new download manager \o/
Xeli
parents: 6049
diff changeset
   150
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   151
		fort.setAdapter(adapter);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   152
		fort.setOnItemSelectedListener(fortSelector);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   153
		fort.setOnFocusChangeListener(focusser);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   154
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   155
		new Thread(this).start();
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   156
	}
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   157
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   158
	public void run(){
6567
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
   159
		final ArrayList<HashMap<String, ?>> gravesDataNew = FrontendDataUtils.getGraves(this);
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   160
		this.runOnUiThread(new Runnable(){
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   161
			public void run() {
6567
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
   162
				copy(gravesData, gravesDataNew);
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   163
				((SimpleAdapter)grave.getAdapter()).notifyDataSetChanged();
6727
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   164
			}
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   165
		});
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   166
		
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   167
		final ArrayList<HashMap<String, ?>> flagsDataNew = FrontendDataUtils.getFlags(this);
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   168
		this.runOnUiThread(new Runnable(){
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   169
			public void run() {
6567
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
   170
				copy(flagsData, flagsDataNew);
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   171
				((SimpleAdapter)flag.getAdapter()).notifyDataSetChanged();
6727
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   172
			}
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   173
		});
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   174
		
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   175
		final ArrayList<HashMap<String, ?>> typesDataNew = FrontendDataUtils.getTypes(this);
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   176
		this.runOnUiThread(new Runnable(){
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   177
			public void run() {
6567
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
   178
				copy(typesData, typesDataNew);
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   179
				((SimpleAdapter)difficulty.getAdapter()).notifyDataSetChanged();
6727
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   180
			}
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   181
		});
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   182
		
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   183
		final ArrayList<HashMap<String, ?>> hatsDataNew = FrontendDataUtils.getHats(this);
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   184
		this.runOnUiThread(new Runnable(){
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   185
			public void run() {
6567
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
   186
				copy(hatsData, hatsDataNew);
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
   187
				((SimpleAdapter)hogHat.get(0).getAdapter()).notifyDataSetChanged();
6727
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   188
			}
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   189
		});
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   190
		
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   191
		final ArrayList<String> voicesDataNew = FrontendDataUtils.getVoices(this);
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   192
		this.runOnUiThread(new Runnable(){
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   193
			public void run() {
6567
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
   194
				copy(voicesData, voicesDataNew);
6726
31582be2ddbc fixed a nullpointer exception when creating a new team
Xeli
parents: 6700
diff changeset
   195
				((ArrayAdapter<String>)voice.getAdapter()).notifyDataSetChanged();
6727
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   196
			}
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   197
		});
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   198
		
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   199
		final ArrayList<String> fortsDataNew = FrontendDataUtils.getForts(this);
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   200
		this.runOnUiThread(new Runnable(){
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   201
			public void run() {
6567
54e19cefcdac Load the TeamCreationmenu's contents in a different thread
Xeli
parents: 6488
diff changeset
   202
				copy(fortsData, fortsDataNew);
6727
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   203
				((ArrayAdapter<String>)fort.getAdapter()).notifyDataSetChanged();
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   204
			}
6727
b3160a49f02e incremental loading of all the images in teamcreation on android, this should really be rewritten though..
Xeli
parents: 6726
diff changeset
   205
		});
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   206
	}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   207
	
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   208
	private static <T> void copy(List<T> dest, List<T> src){
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   209
		for(T t: src) dest.add(t);
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   210
	}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   211
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   212
	public void onDestroy() {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   213
		super.onDestroy();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   214
		if (mp != null) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   215
			mp.release();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   216
			mp = null;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   217
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   218
	}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   219
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   220
	private OnFocusChangeListener focusser = new OnFocusChangeListener() {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   221
		public void onFocusChange(View v, boolean hasFocus) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   222
			settingsChanged = true;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   223
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   224
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   225
	};
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   226
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   227
	public void onBackPressed() {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   228
		onFinishing();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   229
		super.onBackPressed();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   230
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   231
	}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   232
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   233
	private OnClickListener backClicker = new OnClickListener() {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   234
		public void onClick(View v) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   235
			onFinishing();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   236
			finish();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   237
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   238
	};
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   239
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   240
	private void onFinishing() {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   241
		if (settingsChanged) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   242
			setResult(RESULT_OK);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   243
		} else {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   244
			setResult(RESULT_CANCELED);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   245
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   246
	}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   247
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   248
	private OnClickListener saveClicker = new OnClickListener() {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   249
		public void onClick(View v) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   250
			Toast.makeText(TeamCreatorActivity.this, R.string.saved, Toast.LENGTH_SHORT).show();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   251
			saved = true;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   252
			Team team = new Team();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   253
			team.name = name.getText().toString();
6432
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
   254
			HashMap<String, Object> hashmap = (HashMap<String, Object>) flag.getSelectedItem();
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   255
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   256
			team.flag = (String) hashmap.get("txt");
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   257
			team.fort = fort.getSelectedItem().toString();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   258
			hashmap = (HashMap<String, Object>) grave.getSelectedItem();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   259
			team.grave = hashmap.get("txt").toString();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   260
			team.hash = "0";
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   261
			team.voice = voice.getSelectedItem().toString();
6432
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
   262
			team.file = fileName;
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   263
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   264
			hashmap = ((HashMap<String, Object>) difficulty.getSelectedItem());
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   265
			String levelString = hashmap.get("txt").toString();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   266
			int levelInt;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   267
			if (levelString.equals(getString(R.string.human))) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   268
				levelInt = 0;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   269
			} else if (levelString.equals(getString(R.string.bot5))) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   270
				levelInt = 1;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   271
			} else if (levelString.equals(getString(R.string.bot4))) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   272
				levelInt = 2;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   273
			} else if (levelString.equals(getString(R.string.bot3))) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   274
				levelInt = 3;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   275
			} else if (levelString.equals(getString(R.string.bot2))) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   276
				levelInt = 4;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   277
			} else {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   278
				levelInt = 5;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   279
			}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   280
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   281
			for (int i = 0; i < hogName.size(); i++) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   282
				team.hogNames[i] = hogName.get(i).getText().toString();
6432
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
   283
				hashmap = (HashMap<String, Object>) hogHat.get(i).getSelectedItem();
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   284
				team.hats[i] = hashmap.get("txt").toString();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   285
				team.levels[i] = levelInt;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   286
			}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   287
			try {
6432
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
   288
				File teamsDir = new File(getFilesDir().getAbsolutePath() + '/' + Team.DIRECTORY_TEAMS);
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
   289
				if (!teamsDir.exists()) teamsDir.mkdir();
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
   290
				if(team.file == null){
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
   291
					team.setFileName(TeamCreatorActivity.this);
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
   292
				}
ffb18b44415d Use proper names when storing custom teams, also fixes the bug which created new teams when you editted one of the default ones
Xeli
parents: 6350
diff changeset
   293
				FileOutputStream fos = new FileOutputStream(String.format("%s/%s", teamsDir.getAbsolutePath(), team.file));
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   294
				team.writeToXml(fos);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   295
			} catch (FileNotFoundException e) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   296
				e.printStackTrace();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   297
			}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   298
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   299
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   300
	};
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   301
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   302
	private OnItemSelectedListener fortSelector = new OnItemSelectedListener() {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   303
		public void onItemSelected(AdapterView<?> arg0, View arg1,
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   304
				int position, long arg3) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   305
			settingsChanged = true;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   306
			String fortName = (String) arg0.getAdapter().getItem(position);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   307
			Drawable fortIconDrawable = Drawable.createFromPath(Utils
6350
41b0a9955c47 new download manager \o/
Xeli
parents: 6049
diff changeset
   308
					.getDataPath(TeamCreatorActivity.this)
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   309
					+ "Forts/"
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   310
					+ fortName + "L.png");
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   311
			imgFort.setImageDrawable(fortIconDrawable);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   312
			scroller.fullScroll(ScrollView.FOCUS_DOWN);// Scroll the scrollview
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   313
			// to the bottom, work
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   314
			// around for scollview
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   315
			// invalidation (scrolls
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   316
			// back to top)
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   317
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   318
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   319
		public void onNothingSelected(AdapterView<?> arg0) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   320
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   321
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   322
	};
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   323
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   324
	private OnClickListener voiceClicker = new OnClickListener() {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   325
		public void onClick(View v) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   326
			try {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   327
				File dir = new File(String.format("%sSounds/voices/%s",
6350
41b0a9955c47 new download manager \o/
Xeli
parents: 6049
diff changeset
   328
						Utils.getDataPath(TeamCreatorActivity.this),
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   329
						voice.getSelectedItem()));
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   330
				String file = "";
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   331
				File[] dirs = dir.listFiles();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   332
				File f = dirs[(int) Math.round(Math.random() * dirs.length)];
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   333
				if (f.getName().endsWith(".ogg"))
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   334
					file = f.getAbsolutePath();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   335
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   336
				if (mp == null)
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   337
					mp = new MediaPlayer();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   338
				else
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   339
					mp.reset();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   340
				mp.setDataSource(file);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   341
				mp.prepare();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   342
				mp.start();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   343
			} catch (IllegalArgumentException e) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   344
				e.printStackTrace();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   345
			} catch (IllegalStateException e) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   346
				e.printStackTrace();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   347
			} catch (IOException e) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   348
				e.printStackTrace();
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   349
			}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   350
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   351
	};
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   352
6447
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   353
	private void setTeamValues(Team t){
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   354
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   355
		if (t != null) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   356
			name.setText(t.name);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   357
			int position = ((ArrayAdapter<String>) voice.getAdapter()).getPosition(t.voice);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   358
			voice.setSelection(position);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   359
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   360
			position = ((ArrayAdapter<String>) fort.getAdapter()).getPosition(t.fort);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   361
			fort.setSelection(position);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   362
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   363
			position = 0;
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   364
			for (HashMap<String, ?> hashmap : typesData) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   365
				if (hashmap.get("txt").equals(t.levels[0])) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   366
					difficulty.setSelection(position);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   367
					break;
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   368
				}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   369
			}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   370
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   371
			position = 0;
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   372
			for (HashMap<String, ?> hashmap : gravesData) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   373
				if (hashmap.get("txt").equals(t.grave)) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   374
					grave.setSelection(position);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   375
					break;
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   376
				}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   377
			}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   378
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   379
			position = 0;
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   380
			for (HashMap<String, ?> hashmap : typesData) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   381
				if (hashmap.get("txt").equals(t.flag)) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   382
					flag.setSelection(position);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   383
					break;
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   384
				}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   385
			}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   386
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   387
			for (int i = 0; i < Team.maxNumberOfHogs; i++) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   388
				position = 0;
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   389
				for (HashMap<String, ?> hashmap : hatsData) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   390
					if (hashmap.get("txt").equals(t.hats[i])) {
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   391
						hogHat.get(i).setSelection(position);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   392
					}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   393
				}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   394
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   395
				hogName.get(i).setText(t.hogNames[i]);
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   396
			}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   397
			this.fileName = t.file;
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   398
		}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   399
	}
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   400
0bb16bc5c8b4 android: load graphics multithreaded for superduper loadtimes
Xeli
parents: 6432
diff changeset
   401
6047
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   402
	private SimpleAdapter.ViewBinder viewBinder = new SimpleAdapter.ViewBinder() {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   403
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   404
		public boolean setViewValue(View view, Object data,
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   405
				String textRepresentation) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   406
			if (view instanceof ImageView && data instanceof Bitmap) {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   407
				ImageView v = (ImageView) view;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   408
				v.setImageBitmap((Bitmap) data);
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   409
				return true;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   410
			} else {
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   411
				return false;
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   412
			}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   413
		}
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   414
	};
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   415
10011f051f9c Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff changeset
   416
}