author | sheepluva |
Thu, 06 Dec 2012 10:01:01 +0100 | |
changeset 8258 | c14b27abe452 |
parent 7586 | 33924ff4af50 |
child 10017 | de822cd3df3a |
permissions | -rw-r--r-- |
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 | 3 |
* Copyright (c) 2011-2012 Richard Deurwaarder <xeli@xelification.com> |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
4 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com> |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
5 |
* |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
7 |
* modify it under the terms of the GNU General Public License |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
8 |
* as published by the Free Software Foundation; either version 2 |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
9 |
* of the License, or (at your option) any later version. |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
10 |
* |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
11 |
* 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
|
12 |
* 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
|
13 |
* 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
|
14 |
* 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
|
15 |
* |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
16 |
* 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
|
17 |
* along with this program; if not, write to the Free Software |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7508
diff
changeset
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
6047
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 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
21 |
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
|
22 |
|
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.File; |
7485 | 24 |
import java.io.FileNotFoundException; |
6047
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; |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
27 |
import java.util.List; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
6842
diff
changeset
|
28 |
import java.util.Map; |
7485 | 29 |
import java.util.NoSuchElementException; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
30 |
|
6488
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.FrontendDataUtils; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
6842
diff
changeset
|
32 |
import org.hedgewars.hedgeroid.Datastructures.Hog; |
6488
c356ddebab84
android: moved the different objects representing the different game parameters to a different package
Xeli
parents:
6448
diff
changeset
|
33 |
import org.hedgewars.hedgeroid.Datastructures.Team; |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
34 |
import org.hedgewars.hedgeroid.util.FileUtils; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
35 |
|
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.app.Activity; |
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.graphics.Bitmap; |
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.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
|
39 |
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
|
40 |
import android.os.Bundle; |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
41 |
import android.util.Log; |
6047
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.view.View; |
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.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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
import android.widget.Spinner; |
7485 | 55 |
import android.widget.SpinnerAdapter; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
56 |
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
|
57 |
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
|
58 |
|
7485 | 59 |
/** |
60 |
* Edit or create a team. If a team should be edited, it is supplied in the extras |
|
61 |
* as parameter oldTeamName. |
|
62 |
*/ |
|
63 |
public class TeamCreatorActivity extends Activity implements Runnable { |
|
64 |
public static final String PARAMETER_EXISTING_TEAMNAME = "existingTeamName"; |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
65 |
private static final String TAG = TeamCreatorActivity.class.getSimpleName(); |
7485 | 66 |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
private ArrayList<EditText> hogName = new ArrayList<EditText>(); |
7485 | 73 |
private ImageButton voiceButton; |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
74 |
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
|
75 |
private MediaPlayer mp = null; |
7485 | 76 |
private boolean initComplete = false; |
77 |
||
78 |
private String existingTeamName = null; |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
79 |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
80 |
private final List<Map<String, ?>> flagsData = new ArrayList<Map<String, ?>>(); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
81 |
private final List<Map<String, ?>> typesData = new ArrayList<Map<String, ?>>(); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
82 |
private final List<Map<String, ?>> gravesData = new ArrayList<Map<String, ?>>(); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
83 |
private final List<Map<String, ?>> hatsData = new ArrayList<Map<String, ?>>(); |
6567
54e19cefcdac
Load the TeamCreationmenu's contents in a different thread
Xeli
parents:
6488
diff
changeset
|
84 |
private final List<String> voicesData = new ArrayList<String>(); |
54e19cefcdac
Load the TeamCreationmenu's contents in a different thread
Xeli
parents:
6488
diff
changeset
|
85 |
private final List<String> fortsData = new ArrayList<String>(); |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
86 |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
87 |
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
|
88 |
super.onCreate(savedInstanceState); |
7485 | 89 |
initComplete = false; |
90 |
||
91 |
// Restore state and read parameters |
|
92 |
if(savedInstanceState != null) { |
|
93 |
existingTeamName = savedInstanceState.getString(PARAMETER_EXISTING_TEAMNAME); |
|
94 |
} else { |
|
95 |
existingTeamName = getIntent().getStringExtra(PARAMETER_EXISTING_TEAMNAME); |
|
96 |
} |
|
97 |
||
98 |
// Set up view |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
99 |
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
|
100 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
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
|
106 |
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
|
107 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
108 |
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
|
109 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
110 |
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
|
111 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
112 |
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
|
113 |
|
7485 | 114 |
// Wire view elements |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
115 |
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
|
116 |
for (int i = 0; i < ll.getChildCount(); i++) { |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
117 |
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
|
118 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
119 |
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
|
120 |
.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
|
121 |
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
|
122 |
.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
|
123 |
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
|
124 |
.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
|
125 |
} |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
126 |
|
7485 | 127 |
grave.setAdapter(createMapSpinnerAdapter(gravesData)); |
128 |
flag.setAdapter(createMapSpinnerAdapter(flagsData)); |
|
129 |
difficulty.setAdapter(createMapSpinnerAdapter(typesData)); |
|
130 |
SpinnerAdapter hatAdapter = createMapSpinnerAdapter(hatsData); |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
131 |
for (Spinner spin : hogHat) { |
7485 | 132 |
spin.setAdapter(hatAdapter); |
6047
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 |
|
7485 | 135 |
|
136 |
voice.setAdapter(createListSpinnerAdapter(voicesData)); |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
137 |
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
|
138 |
|
7485 | 139 |
fort.setAdapter(createListSpinnerAdapter(fortsData)); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
140 |
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
|
141 |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
142 |
new Thread(this).start(); |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
143 |
} |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
144 |
|
7485 | 145 |
private SpinnerAdapter createMapSpinnerAdapter(List<? extends Map<String, ?>> data) { |
146 |
SimpleAdapter sa = new SimpleAdapter(this, data, |
|
147 |
R.layout.spinner_textimg_entry, new String[] { "txt", "img" }, |
|
148 |
new int[] { R.id.spinner_txt, R.id.spinner_img }); |
|
149 |
sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
|
150 |
sa.setViewBinder(viewBinder); |
|
151 |
return sa; |
|
152 |
} |
|
153 |
||
154 |
private SpinnerAdapter createListSpinnerAdapter(List<String> data) { |
|
155 |
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.listview_item, data); |
|
156 |
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
157 |
return adapter; |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
158 |
} |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
159 |
|
7485 | 160 |
public void run(){ |
161 |
try { |
|
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
162 |
final List<Map<String, ?>> gravesDataNew = FrontendDataUtils.getGraves(this); |
7485 | 163 |
runOnUiThread(new Runnable(){ |
164 |
public void run() { |
|
165 |
gravesData.addAll(gravesDataNew); |
|
166 |
((SimpleAdapter)grave.getAdapter()).notifyDataSetChanged(); |
|
167 |
} |
|
168 |
}); |
|
169 |
||
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
170 |
final List<Map<String, ?>> flagsDataNew = FrontendDataUtils.getFlags(this); |
7485 | 171 |
runOnUiThread(new Runnable(){ |
172 |
public void run() { |
|
173 |
flagsData.addAll(flagsDataNew); |
|
174 |
((SimpleAdapter)flag.getAdapter()).notifyDataSetChanged(); |
|
175 |
} |
|
176 |
}); |
|
177 |
||
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
178 |
final List<Map<String, ?>> typesDataNew = FrontendDataUtils.getTypes(this); |
7485 | 179 |
runOnUiThread(new Runnable(){ |
180 |
public void run() { |
|
181 |
typesData.addAll(typesDataNew); |
|
182 |
((SimpleAdapter)difficulty.getAdapter()).notifyDataSetChanged(); |
|
183 |
} |
|
184 |
}); |
|
185 |
||
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
186 |
final List<Map<String, ?>> hatsDataNew = FrontendDataUtils.getHats(this); |
7485 | 187 |
runOnUiThread(new Runnable(){ |
188 |
public void run() { |
|
189 |
hatsData.addAll(hatsDataNew); |
|
190 |
((SimpleAdapter)hogHat.get(0).getAdapter()).notifyDataSetChanged(); |
|
191 |
} |
|
192 |
}); |
|
193 |
||
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
194 |
final List<String> voicesDataNew = FrontendDataUtils.getVoices(this); |
7485 | 195 |
runOnUiThread(new Runnable(){ |
196 |
public void run() { |
|
197 |
voicesData.addAll(voicesDataNew); |
|
198 |
((ArrayAdapter<?>)voice.getAdapter()).notifyDataSetChanged(); |
|
199 |
} |
|
200 |
}); |
|
201 |
||
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
202 |
final List<String> fortsDataNew = FrontendDataUtils.getForts(this); |
7485 | 203 |
runOnUiThread(new Runnable(){ |
204 |
public void run() { |
|
205 |
fortsData.addAll(fortsDataNew); |
|
206 |
((ArrayAdapter<?>)fort.getAdapter()).notifyDataSetChanged(); |
|
207 |
} |
|
208 |
}); |
|
209 |
||
210 |
if(existingTeamName!=null) { |
|
211 |
final Team loadedTeam = Team.load(Team.getTeamfileByName(getApplicationContext(), existingTeamName)); |
|
212 |
if(loadedTeam==null) { |
|
213 |
existingTeamName = null; |
|
214 |
} else { |
|
215 |
runOnUiThread(new Runnable(){ |
|
216 |
public void run() { |
|
217 |
setTeamValues(loadedTeam); |
|
218 |
} |
|
219 |
}); |
|
220 |
} |
|
221 |
} |
|
222 |
runOnUiThread(new Runnable(){ |
|
223 |
public void run() { |
|
224 |
initComplete = true; |
|
225 |
} |
|
226 |
}); |
|
227 |
} catch(FileNotFoundException e) { |
|
228 |
this.runOnUiThread(new Runnable(){ |
|
229 |
public void run() { |
|
230 |
Toast.makeText(getApplicationContext(), R.string.error_missing_sdcard_or_files, Toast.LENGTH_LONG).show(); |
|
231 |
finish(); |
|
232 |
} |
|
233 |
}); |
|
234 |
} |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
235 |
} |
7485 | 236 |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
237 |
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
|
238 |
super.onDestroy(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
239 |
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
|
240 |
mp.release(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
241 |
mp = null; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
242 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
243 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
244 |
|
7485 | 245 |
@Override |
246 |
protected void onSaveInstanceState(Bundle outState) { |
|
247 |
super.onSaveInstanceState(outState); |
|
248 |
outState.putString(PARAMETER_EXISTING_TEAMNAME, existingTeamName); |
|
249 |
} |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
250 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
251 |
public void onBackPressed() { |
7485 | 252 |
if(initComplete) { |
253 |
saveTeam(); |
|
254 |
} |
|
255 |
setResult(RESULT_OK); |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
256 |
super.onBackPressed(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
257 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
258 |
|
7485 | 259 |
private void saveTeam() { |
260 |
String teamName = name.getText().toString(); |
|
261 |
String teamFlag = (String)((Map<String, Object>) flag.getSelectedItem()).get("txt"); |
|
262 |
String teamFort = fort.getSelectedItem().toString(); |
|
263 |
String teamGrave = (String)((Map<String, Object>) grave.getSelectedItem()).get("txt"); |
|
264 |
String teamVoice = voice.getSelectedItem().toString(); |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
265 |
int levelInt = (Integer)((Map<String, Object>) difficulty.getSelectedItem()).get("level"); |
7485 | 266 |
|
267 |
List<Hog> hogs = new ArrayList<Hog>(); |
|
268 |
for (int i = 0; i < hogName.size(); i++) { |
|
269 |
String name = hogName.get(i).getText().toString(); |
|
270 |
String hat = ((Map<String, Object>) hogHat.get(i).getSelectedItem()).get("txt").toString(); |
|
271 |
hogs.add(new Hog(name, hat, levelInt)); |
|
272 |
} |
|
273 |
||
274 |
Team team = new Team(teamName, teamGrave, teamFlag, teamVoice, teamFort, hogs); |
|
275 |
File teamsDir = new File(getFilesDir(), Team.DIRECTORY_TEAMS); |
|
276 |
if (!teamsDir.exists()) teamsDir.mkdir(); |
|
277 |
||
278 |
File newFile = Team.getTeamfileByName(this, teamName); |
|
279 |
File oldFile = null; |
|
280 |
if(existingTeamName != null) { |
|
281 |
oldFile = Team.getTeamfileByName(this, existingTeamName); |
|
282 |
} |
|
283 |
try { |
|
284 |
team.save(newFile); |
|
285 |
// If the team was renamed, delete the old file. |
|
286 |
if(oldFile != null && oldFile.isFile() && !oldFile.equals(newFile)) { |
|
287 |
oldFile.delete(); |
|
288 |
} |
|
289 |
existingTeamName = teamName; |
|
290 |
} catch(IOException e) { |
|
291 |
Toast.makeText(getApplicationContext(), R.string.error_save_failed, Toast.LENGTH_SHORT).show(); |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
292 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
293 |
}; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
294 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
295 |
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
|
296 |
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
|
297 |
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
|
298 |
String fortName = (String) arg0.getAdapter().getItem(position); |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
299 |
try { |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
300 |
File fortImage = FileUtils.getDataPathFile(TeamCreatorActivity.this, "Forts", fortName, "L.png"); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
301 |
Drawable fortIconDrawable = Drawable.createFromPath(fortImage.getAbsolutePath()); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
302 |
imgFort.setImageDrawable(fortIconDrawable); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
303 |
} catch(IOException e) { |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
304 |
Log.e(TAG, "Unable to show fort image", e); |
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
305 |
} |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
306 |
scroller.fullScroll(ScrollView.FOCUS_DOWN);// Scroll the scrollview |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
307 |
// to the bottom, work |
6842
2e6391f33204
Removed some unused imports and a redundand nullcheck
Medo <smaxein@googlemail.com>
parents:
6727
diff
changeset
|
308 |
// around for scrollview |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
309 |
// invalidation (scrolls |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
310 |
// 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
|
311 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
312 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
313 |
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
|
314 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
315 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
316 |
}; |
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 |
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
|
319 |
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
|
320 |
try { |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
321 |
File dir = FileUtils.getDataPathFile(TeamCreatorActivity.this, "Sounds", "voices", (String)voice.getSelectedItem()); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
322 |
String file = ""; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
323 |
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
|
324 |
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
|
325 |
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
|
326 |
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
|
327 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
328 |
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
|
329 |
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
|
330 |
else |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
331 |
mp.reset(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
332 |
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
|
333 |
mp.prepare(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
334 |
mp.start(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
335 |
} catch (IllegalArgumentException e) { |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
336 |
Log.e(TAG, "Unable to play voice sample", e); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
337 |
} catch (IllegalStateException e) { |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
338 |
Log.e(TAG, "Unable to play voice sample", e); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
339 |
} catch (IOException e) { |
7586
33924ff4af50
Hedgeroid: Some code cleanup, adding a forgotten file
Medo <smaxein@googlemail.com>
parents:
7584
diff
changeset
|
340 |
Log.e(TAG, "Unable to play voice sample", e); |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
341 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
342 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
343 |
}; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
344 |
|
7485 | 345 |
@SuppressWarnings("unchecked") |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
346 |
private void setTeamValues(Team t){ |
7485 | 347 |
if (t == null) { |
348 |
return; |
|
349 |
} |
|
350 |
||
351 |
try { |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
352 |
name.setText(t.name); |
7485 | 353 |
voice.setSelection(findPosition((ArrayAdapter<String>) voice.getAdapter(), t.voice)); |
354 |
fort.setSelection(findPosition((ArrayAdapter<String>) fort.getAdapter(), t.fort)); |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
355 |
difficulty.setSelection(findPosition(typesData, "level", Integer.valueOf(t.hogs.get(0).level))); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
356 |
grave.setSelection(findPosition(gravesData, "txt", t.grave)); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
357 |
flag.setSelection(findPosition(flagsData, "txt", t.flag)); |
7485 | 358 |
|
359 |
for (int i = 0; i < Team.HEDGEHOGS_PER_TEAM; i++) { |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
360 |
hogHat.get(i).setSelection(findPosition(hatsData, "txt", t.hogs.get(i).hat)); |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
6842
diff
changeset
|
361 |
hogName.get(i).setText(t.hogs.get(i).name); |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
362 |
} |
7485 | 363 |
} catch(NoSuchElementException e) { |
364 |
Toast.makeText(getApplicationContext(), R.string.error_team_attribute_not_found, Toast.LENGTH_LONG).show(); |
|
365 |
finish(); |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
366 |
} |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
367 |
} |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
368 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
369 |
int findPosition(ArrayAdapter<String> adapter, String value) throws NoSuchElementException { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
370 |
int position = adapter.getPosition(value); |
7485 | 371 |
if(position<0) { |
372 |
throw new NoSuchElementException(); |
|
373 |
} |
|
374 |
return position; |
|
375 |
} |
|
376 |
||
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
377 |
int findPosition(List<? extends Map<String, ?>> data, String key, Object value) throws NoSuchElementException { |
7485 | 378 |
int position = 0; |
379 |
for (Map<String, ?> map : data) { |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
380 |
if (map.get(key).equals(value)) { |
7485 | 381 |
return position; |
382 |
} |
|
383 |
position++; |
|
384 |
} |
|
385 |
throw new NoSuchElementException(); |
|
386 |
} |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
387 |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
388 |
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
|
389 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
390 |
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
|
391 |
String textRepresentation) { |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
392 |
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
|
393 |
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
|
394 |
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
|
395 |
return true; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
396 |
} else { |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
397 |
return false; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
398 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
399 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
400 |
}; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
401 |
} |