88 save.setOnClickListener(saveClicker); |
93 save.setOnClickListener(saveClicker); |
89 back.setOnClickListener(backClicker); |
94 back.setOnClickListener(backClicker); |
90 |
95 |
91 LinearLayout ll = (LinearLayout) findViewById(R.id.HogsContainer); |
96 LinearLayout ll = (LinearLayout) findViewById(R.id.HogsContainer); |
92 for (int i = 0; i < ll.getChildCount(); i++) { |
97 for (int i = 0; i < ll.getChildCount(); i++) { |
93 RelativeLayout team_creation_entry = (RelativeLayout) ll |
98 RelativeLayout team_creation_entry = (RelativeLayout) ll.getChildAt(i); |
94 .getChildAt(i); |
|
95 |
99 |
96 hogHat.add((Spinner) team_creation_entry |
100 hogHat.add((Spinner) team_creation_entry |
97 .findViewById(R.id.spinTeam1)); |
101 .findViewById(R.id.spinTeam1)); |
98 hogDice.add((ImageButton) team_creation_entry |
102 hogDice.add((ImageButton) team_creation_entry |
99 .findViewById(R.id.btnTeam1)); |
103 .findViewById(R.id.btnTeam1)); |
100 hogName.add((EditText) team_creation_entry |
104 hogName.add((EditText) team_creation_entry |
101 .findViewById(R.id.txtTeam1)); |
105 .findViewById(R.id.txtTeam1)); |
102 } |
106 } |
103 ArrayList<HashMap<String, ?>> gravesData = FrontendDataUtils.getGraves(this); |
107 |
|
108 gravesData = new ArrayList<HashMap<String, ?>>(); |
104 SimpleAdapter sa = new SimpleAdapter(this, gravesData, |
109 SimpleAdapter sa = new SimpleAdapter(this, gravesData, |
105 R.layout.spinner_textimg_entry, new String[] { "txt", "img" }, |
110 R.layout.spinner_textimg_entry, new String[] { "txt", "img" }, |
106 new int[] { R.id.spinner_txt, R.id.spinner_img }); |
111 new int[] { R.id.spinner_txt, R.id.spinner_img }); |
107 sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
112 sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
108 sa.setViewBinder(viewBinder); |
113 sa.setViewBinder(viewBinder); |
109 grave.setAdapter(sa); |
114 grave.setAdapter(sa); |
110 grave.setOnFocusChangeListener(focusser); |
115 grave.setOnFocusChangeListener(focusser); |
111 |
116 |
112 ArrayList<HashMap<String, ?>> flagsData = FrontendDataUtils |
117 flagsData = new ArrayList<HashMap<String, ?>>(); |
113 .getFlags(this); |
|
114 sa = new SimpleAdapter(this, flagsData, R.layout.spinner_textimg_entry, |
118 sa = new SimpleAdapter(this, flagsData, R.layout.spinner_textimg_entry, |
115 new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, |
119 new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, |
116 R.id.spinner_img }); |
120 R.id.spinner_img }); |
117 sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
121 sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
118 sa.setViewBinder(viewBinder); |
122 sa.setViewBinder(viewBinder); |
119 flag.setAdapter(sa); |
123 flag.setAdapter(sa); |
120 flag.setOnFocusChangeListener(focusser); |
124 flag.setOnFocusChangeListener(focusser); |
121 |
125 |
122 ArrayList<HashMap<String, ?>> typesData = FrontendDataUtils |
126 typesData = new ArrayList<HashMap<String, ?>>(); |
123 .getTypes(this); |
|
124 sa = new SimpleAdapter(this, typesData, R.layout.spinner_textimg_entry, |
127 sa = new SimpleAdapter(this, typesData, R.layout.spinner_textimg_entry, |
125 new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, |
128 new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, |
126 R.id.spinner_img }); |
129 R.id.spinner_img }); |
127 sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
130 sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
128 difficulty.setAdapter(sa); |
131 difficulty.setAdapter(sa); |
129 difficulty.setOnFocusChangeListener(focusser); |
132 difficulty.setOnFocusChangeListener(focusser); |
130 |
133 |
131 ArrayList<HashMap<String, ?>> hatsData = FrontendDataUtils |
134 hatsData = new ArrayList<HashMap<String, ?>>(); |
132 .getHats(this); |
|
133 sa = new SimpleAdapter(this, hatsData, R.layout.spinner_textimg_entry, |
135 sa = new SimpleAdapter(this, hatsData, R.layout.spinner_textimg_entry, |
134 new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, |
136 new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, |
135 R.id.spinner_img }); |
137 R.id.spinner_img }); |
136 sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
138 sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry); |
137 sa.setViewBinder(viewBinder); |
139 sa.setViewBinder(viewBinder); |
138 for (Spinner spin : hogHat) { |
140 for (Spinner spin : hogHat) { |
139 spin.setAdapter(sa); |
141 spin.setAdapter(sa); |
140 } |
142 } |
141 |
143 |
142 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, |
144 voicesData = new ArrayList<String>(); |
143 R.layout.listview_item, FrontendDataUtils.getVoices(this)); |
145 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.listview_item, voicesData); |
144 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
146 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
145 voice.setAdapter(adapter); |
147 voice.setAdapter(adapter); |
146 voice.setOnFocusChangeListener(focusser); |
148 voice.setOnFocusChangeListener(focusser); |
147 voiceButton.setOnClickListener(voiceClicker); |
149 voiceButton.setOnClickListener(voiceClicker); |
148 |
150 |
149 adapter = new ArrayAdapter<String>(this, R.layout.listview_item, |
151 fortsData = new ArrayList<String>(); |
150 FrontendDataUtils.getForts(this)); |
152 adapter = new ArrayAdapter<String>(this, R.layout.listview_item, fortsData); |
151 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
153 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
152 fort.setAdapter(adapter); |
154 fort.setAdapter(adapter); |
153 fort.setOnItemSelectedListener(fortSelector); |
155 fort.setOnItemSelectedListener(fortSelector); |
154 fort.setOnFocusChangeListener(focusser); |
156 fort.setOnFocusChangeListener(focusser); |
155 |
157 |
156 Team t = this.getIntent().getParcelableExtra("team"); |
158 new Thread(this).start(); |
157 if (t != null) { |
159 } |
158 name.setText(t.name); |
160 |
159 int position = ((ArrayAdapter<String>) voice.getAdapter()) |
161 public void run(){ |
160 .getPosition(t.voice); |
162 try { |
161 voice.setSelection(position); |
163 Thread.sleep(2000); |
162 |
164 } catch (InterruptedException e) { |
163 position = ((ArrayAdapter<String>) fort.getAdapter()) |
165 // TODO Auto-generated catch block |
164 .getPosition(t.fort); |
166 e.printStackTrace(); |
165 fort.setSelection(position); |
167 } |
166 |
168 ArrayList<HashMap<String, ?>> gravesData = FrontendDataUtils.getGraves(this); |
167 position = 0; |
169 ArrayList<HashMap<String, ?>> flagsData = FrontendDataUtils.getFlags(this); |
168 for (HashMap<String, ?> hashmap : typesData) { |
170 ArrayList<HashMap<String, ?>> typesData = FrontendDataUtils.getTypes(this); |
169 if (hashmap.get("txt").equals(t.levels[0])) { |
171 ArrayList<HashMap<String, ?>> hatsData = FrontendDataUtils.getHats(this); |
170 difficulty.setSelection(position); |
172 ArrayList<String> voicesData = FrontendDataUtils.getVoices(this); |
171 break; |
173 ArrayList<String> fortsData = FrontendDataUtils.getForts(this); |
172 } |
174 |
173 } |
175 copy(this.gravesData, gravesData); |
174 |
176 copy(this.flagsData, flagsData); |
175 position = 0; |
177 copy(this.typesData, typesData); |
176 for (HashMap<String, ?> hashmap : gravesData) { |
178 copy(this.hatsData, hatsData); |
177 if (hashmap.get("txt").equals(t.grave)) { |
179 copy(this.voicesData, voicesData); |
178 grave.setSelection(position); |
180 copy(this.fortsData, fortsData); |
179 break; |
181 |
180 } |
182 this.runOnUiThread(new Runnable(){ |
181 } |
183 public void run() { |
182 |
184 ((SimpleAdapter)grave.getAdapter()).notifyDataSetChanged(); |
183 position = 0; |
185 ((SimpleAdapter)flag.getAdapter()).notifyDataSetChanged(); |
184 for (HashMap<String, ?> hashmap : typesData) { |
186 ((SimpleAdapter)difficulty.getAdapter()).notifyDataSetChanged(); |
185 if (hashmap.get("txt").equals(t.flag)) { |
187 ((SimpleAdapter)hogHat.get(0).getAdapter()).notifyDataSetChanged(); |
186 flag.setSelection(position); |
188 ((ArrayAdapter<String>)fort.getAdapter()).notifyDataSetChanged(); |
187 break; |
189 ((ArrayAdapter<String>)voice.getAdapter()).notifyDataSetChanged(); |
188 } |
190 } |
189 } |
191 }); |
190 |
192 |
191 for (int i = 0; i < Team.maxNumberOfHogs; i++) { |
193 } |
192 position = 0; |
194 |
193 for (HashMap<String, ?> hashmap : hatsData) { |
195 private static <T> void copy(List<T> dest, List<T> src){ |
194 if (hashmap.get("txt").equals(t.hats[i])) { |
196 for(T t: src) dest.add(t); |
195 hogHat.get(i).setSelection(position); |
|
196 } |
|
197 } |
|
198 |
|
199 hogName.get(i).setText(t.hogNames[i]); |
|
200 } |
|
201 this.fileName = t.file; |
|
202 } |
|
203 } |
197 } |
204 |
198 |
205 public void onDestroy() { |
199 public void onDestroy() { |
206 super.onDestroy(); |
200 super.onDestroy(); |
207 if (mp != null) { |
201 if (mp != null) { |