author | Medo <smaxein@googlemail.com> |
Sat, 18 Aug 2012 13:39:05 +0200 | |
changeset 7558 | 983ff426f91e |
parent 7508 | 763d3961400b |
child 7584 | 7831c84cc644 |
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> |
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; |
7485 | 23 |
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
|
24 |
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
|
25 |
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
|
26 |
import java.util.HashMap; |
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; |
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.view.View; |
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.OnClickListener; |
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.AdapterView; |
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.OnItemSelectedListener; |
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.ArrayAdapter; |
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.EditText; |
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.ImageButton; |
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.ImageView; |
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.LinearLayout; |
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.RelativeLayout; |
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.ScrollView; |
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.SimpleAdapter; |
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.Spinner; |
7485 | 54 |
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
|
55 |
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
|
56 |
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
|
57 |
|
7485 | 58 |
/** |
59 |
* Edit or create a team. If a team should be edited, it is supplied in the extras |
|
60 |
* as parameter oldTeamName. |
|
61 |
*/ |
|
62 |
public class TeamCreatorActivity extends Activity implements Runnable { |
|
63 |
public static final String PARAMETER_EXISTING_TEAMNAME = "existingTeamName"; |
|
64 |
||
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
private ArrayList<EditText> hogName = new ArrayList<EditText>(); |
7485 | 71 |
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
|
72 |
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
|
73 |
private MediaPlayer mp = null; |
7485 | 74 |
private boolean initComplete = false; |
75 |
||
76 |
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
|
77 |
|
6567
54e19cefcdac
Load the TeamCreationmenu's contents in a different thread
Xeli
parents:
6488
diff
changeset
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
private final List<String> voicesData = new ArrayList<String>(); |
54e19cefcdac
Load the TeamCreationmenu's contents in a different thread
Xeli
parents:
6488
diff
changeset
|
83 |
private final List<String> fortsData = new ArrayList<String>(); |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
84 |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
85 |
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
|
86 |
super.onCreate(savedInstanceState); |
7485 | 87 |
initComplete = false; |
88 |
||
89 |
// Restore state and read parameters |
|
90 |
if(savedInstanceState != null) { |
|
91 |
existingTeamName = savedInstanceState.getString(PARAMETER_EXISTING_TEAMNAME); |
|
92 |
} else { |
|
93 |
existingTeamName = getIntent().getStringExtra(PARAMETER_EXISTING_TEAMNAME); |
|
94 |
} |
|
95 |
||
96 |
// 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
|
97 |
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
|
98 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
106 |
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
|
107 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
108 |
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
|
109 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
110 |
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
|
111 |
|
7485 | 112 |
// 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
|
113 |
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
|
114 |
for (int i = 0; i < ll.getChildCount(); i++) { |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
115 |
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
|
116 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
117 |
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
|
118 |
.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
|
119 |
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
|
120 |
.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
|
121 |
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
|
122 |
.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
|
123 |
} |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
124 |
|
7485 | 125 |
grave.setAdapter(createMapSpinnerAdapter(gravesData)); |
126 |
flag.setAdapter(createMapSpinnerAdapter(flagsData)); |
|
127 |
difficulty.setAdapter(createMapSpinnerAdapter(typesData)); |
|
128 |
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
|
129 |
for (Spinner spin : hogHat) { |
7485 | 130 |
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
|
131 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
132 |
|
7485 | 133 |
|
134 |
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
|
135 |
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
|
136 |
|
7485 | 137 |
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
|
138 |
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
|
139 |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
140 |
new Thread(this).start(); |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
141 |
} |
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
142 |
|
7485 | 143 |
private SpinnerAdapter createMapSpinnerAdapter(List<? extends Map<String, ?>> data) { |
144 |
SimpleAdapter sa = new SimpleAdapter(this, data, |
|
145 |
R.layout.spinner_textimg_entry, new String[] { "txt", "img" }, |
|
146 |
new int[] { R.id.spinner_txt, R.id.spinner_img }); |
|
147 |
sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
|
148 |
sa.setViewBinder(viewBinder); |
|
149 |
return sa; |
|
150 |
} |
|
151 |
||
152 |
private SpinnerAdapter createListSpinnerAdapter(List<String> data) { |
|
153 |
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.listview_item, data); |
|
154 |
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
155 |
return adapter; |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
156 |
} |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
157 |
|
7485 | 158 |
public void run(){ |
159 |
try { |
|
160 |
final ArrayList<HashMap<String, ?>> gravesDataNew = FrontendDataUtils.getGraves(this); |
|
161 |
runOnUiThread(new Runnable(){ |
|
162 |
public void run() { |
|
163 |
gravesData.addAll(gravesDataNew); |
|
164 |
((SimpleAdapter)grave.getAdapter()).notifyDataSetChanged(); |
|
165 |
} |
|
166 |
}); |
|
167 |
||
168 |
final ArrayList<HashMap<String, ?>> flagsDataNew = FrontendDataUtils.getFlags(this); |
|
169 |
runOnUiThread(new Runnable(){ |
|
170 |
public void run() { |
|
171 |
flagsData.addAll(flagsDataNew); |
|
172 |
((SimpleAdapter)flag.getAdapter()).notifyDataSetChanged(); |
|
173 |
} |
|
174 |
}); |
|
175 |
||
176 |
final ArrayList<HashMap<String, ?>> typesDataNew = FrontendDataUtils.getTypes(this); |
|
177 |
runOnUiThread(new Runnable(){ |
|
178 |
public void run() { |
|
179 |
typesData.addAll(typesDataNew); |
|
180 |
((SimpleAdapter)difficulty.getAdapter()).notifyDataSetChanged(); |
|
181 |
} |
|
182 |
}); |
|
183 |
||
184 |
final ArrayList<HashMap<String, ?>> hatsDataNew = FrontendDataUtils.getHats(this); |
|
185 |
runOnUiThread(new Runnable(){ |
|
186 |
public void run() { |
|
187 |
hatsData.addAll(hatsDataNew); |
|
188 |
((SimpleAdapter)hogHat.get(0).getAdapter()).notifyDataSetChanged(); |
|
189 |
} |
|
190 |
}); |
|
191 |
||
192 |
final ArrayList<String> voicesDataNew = FrontendDataUtils.getVoices(this); |
|
193 |
runOnUiThread(new Runnable(){ |
|
194 |
public void run() { |
|
195 |
voicesData.addAll(voicesDataNew); |
|
196 |
((ArrayAdapter<?>)voice.getAdapter()).notifyDataSetChanged(); |
|
197 |
} |
|
198 |
}); |
|
199 |
||
200 |
final ArrayList<String> fortsDataNew = FrontendDataUtils.getForts(this); |
|
201 |
runOnUiThread(new Runnable(){ |
|
202 |
public void run() { |
|
203 |
fortsData.addAll(fortsDataNew); |
|
204 |
((ArrayAdapter<?>)fort.getAdapter()).notifyDataSetChanged(); |
|
205 |
} |
|
206 |
}); |
|
207 |
||
208 |
if(existingTeamName!=null) { |
|
209 |
final Team loadedTeam = Team.load(Team.getTeamfileByName(getApplicationContext(), existingTeamName)); |
|
210 |
if(loadedTeam==null) { |
|
211 |
existingTeamName = null; |
|
212 |
} else { |
|
213 |
runOnUiThread(new Runnable(){ |
|
214 |
public void run() { |
|
215 |
setTeamValues(loadedTeam); |
|
216 |
} |
|
217 |
}); |
|
218 |
} |
|
219 |
} |
|
220 |
runOnUiThread(new Runnable(){ |
|
221 |
public void run() { |
|
222 |
initComplete = true; |
|
223 |
} |
|
224 |
}); |
|
225 |
} catch(FileNotFoundException e) { |
|
226 |
this.runOnUiThread(new Runnable(){ |
|
227 |
public void run() { |
|
228 |
Toast.makeText(getApplicationContext(), R.string.error_missing_sdcard_or_files, Toast.LENGTH_LONG).show(); |
|
229 |
finish(); |
|
230 |
} |
|
231 |
}); |
|
232 |
} |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
233 |
} |
7485 | 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 |
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
|
236 |
super.onDestroy(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
237 |
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
|
238 |
mp.release(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
239 |
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 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
241 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
242 |
|
7485 | 243 |
@Override |
244 |
protected void onSaveInstanceState(Bundle outState) { |
|
245 |
super.onSaveInstanceState(outState); |
|
246 |
outState.putString(PARAMETER_EXISTING_TEAMNAME, existingTeamName); |
|
247 |
} |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
248 |
|
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 onBackPressed() { |
7485 | 250 |
if(initComplete) { |
251 |
saveTeam(); |
|
252 |
} |
|
253 |
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
|
254 |
super.onBackPressed(); |
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 |
|
7485 | 257 |
private void saveTeam() { |
258 |
String teamName = name.getText().toString(); |
|
259 |
String teamFlag = (String)((Map<String, Object>) flag.getSelectedItem()).get("txt"); |
|
260 |
String teamFort = fort.getSelectedItem().toString(); |
|
261 |
String teamGrave = (String)((Map<String, Object>) grave.getSelectedItem()).get("txt"); |
|
262 |
String teamVoice = voice.getSelectedItem().toString(); |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
263 |
int levelInt = (Integer)((Map<String, Object>) difficulty.getSelectedItem()).get("level"); |
7485 | 264 |
|
265 |
List<Hog> hogs = new ArrayList<Hog>(); |
|
266 |
for (int i = 0; i < hogName.size(); i++) { |
|
267 |
String name = hogName.get(i).getText().toString(); |
|
268 |
String hat = ((Map<String, Object>) hogHat.get(i).getSelectedItem()).get("txt").toString(); |
|
269 |
hogs.add(new Hog(name, hat, levelInt)); |
|
270 |
} |
|
271 |
||
272 |
Team team = new Team(teamName, teamGrave, teamFlag, teamVoice, teamFort, hogs); |
|
273 |
File teamsDir = new File(getFilesDir(), Team.DIRECTORY_TEAMS); |
|
274 |
if (!teamsDir.exists()) teamsDir.mkdir(); |
|
275 |
||
276 |
File newFile = Team.getTeamfileByName(this, teamName); |
|
277 |
File oldFile = null; |
|
278 |
if(existingTeamName != null) { |
|
279 |
oldFile = Team.getTeamfileByName(this, existingTeamName); |
|
280 |
} |
|
281 |
try { |
|
282 |
team.save(newFile); |
|
283 |
// If the team was renamed, delete the old file. |
|
284 |
if(oldFile != null && oldFile.isFile() && !oldFile.equals(newFile)) { |
|
285 |
oldFile.delete(); |
|
286 |
} |
|
287 |
existingTeamName = teamName; |
|
288 |
} catch(IOException e) { |
|
289 |
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
|
290 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
291 |
}; |
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 |
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
|
294 |
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
|
295 |
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
|
296 |
String fortName = (String) arg0.getAdapter().getItem(position); |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
297 |
Drawable fortIconDrawable = Drawable.createFromPath(FileUtils |
6350 | 298 |
.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
|
299 |
+ "Forts/" |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
300 |
+ 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
|
301 |
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
|
302 |
scroller.fullScroll(ScrollView.FOCUS_DOWN);// Scroll the scrollview |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
303 |
// to the bottom, work |
6842
2e6391f33204
Removed some unused imports and a redundand nullcheck
Medo <smaxein@googlemail.com>
parents:
6727
diff
changeset
|
304 |
// around for scrollview |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
305 |
// invalidation (scrolls |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
306 |
// 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
|
307 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
308 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
309 |
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
|
310 |
} |
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 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
314 |
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
|
315 |
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
|
316 |
try { |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
317 |
File dir = new File(String.format("%sSounds/voices/%s", |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
318 |
FileUtils.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
|
319 |
voice.getSelectedItem())); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
320 |
String file = ""; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
321 |
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
|
322 |
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
|
323 |
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
|
324 |
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
|
325 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
326 |
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
|
327 |
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
|
328 |
else |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
329 |
mp.reset(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
330 |
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
|
331 |
mp.prepare(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
332 |
mp.start(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
333 |
} 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
|
334 |
e.printStackTrace(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
335 |
} 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
|
336 |
e.printStackTrace(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
337 |
} 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
|
338 |
e.printStackTrace(); |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
339 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
340 |
} |
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 |
|
7485 | 343 |
@SuppressWarnings("unchecked") |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
344 |
private void setTeamValues(Team t){ |
7485 | 345 |
if (t == null) { |
346 |
return; |
|
347 |
} |
|
348 |
||
349 |
try { |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
350 |
name.setText(t.name); |
7485 | 351 |
voice.setSelection(findPosition((ArrayAdapter<String>) voice.getAdapter(), t.voice)); |
352 |
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
|
353 |
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
|
354 |
grave.setSelection(findPosition(gravesData, "txt", t.grave)); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
355 |
flag.setSelection(findPosition(flagsData, "txt", t.flag)); |
7485 | 356 |
|
357 |
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
|
358 |
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
|
359 |
hogName.get(i).setText(t.hogs.get(i).name); |
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
360 |
} |
7485 | 361 |
} catch(NoSuchElementException e) { |
362 |
Toast.makeText(getApplicationContext(), R.string.error_team_attribute_not_found, Toast.LENGTH_LONG).show(); |
|
363 |
finish(); |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
364 |
} |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
365 |
} |
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
366 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
367 |
int findPosition(ArrayAdapter<String> adapter, String value) throws NoSuchElementException { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
368 |
int position = adapter.getPosition(value); |
7485 | 369 |
if(position<0) { |
370 |
throw new NoSuchElementException(); |
|
371 |
} |
|
372 |
return position; |
|
373 |
} |
|
374 |
||
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
375 |
int findPosition(List<? extends Map<String, ?>> data, String key, Object value) throws NoSuchElementException { |
7485 | 376 |
int position = 0; |
377 |
for (Map<String, ?> map : data) { |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
378 |
if (map.get(key).equals(value)) { |
7485 | 379 |
return position; |
380 |
} |
|
381 |
position++; |
|
382 |
} |
|
383 |
throw new NoSuchElementException(); |
|
384 |
} |
|
6447
0bb16bc5c8b4
android: load graphics multithreaded for superduper loadtimes
Xeli
parents:
6432
diff
changeset
|
385 |
|
6047
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
386 |
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
|
387 |
|
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
388 |
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
|
389 |
String textRepresentation) { |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
390 |
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
|
391 |
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
|
392 |
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
|
393 |
return true; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
394 |
} else { |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
395 |
return false; |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
396 |
} |
10011f051f9c
Changed package name from org.hedgewars.mobile to org.hedgewars.hedgeroid to upload it to the market
Xeli
parents:
diff
changeset
|
397 |
} |
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 |
} |