1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Distorted is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.examples;
|
21
|
|
22
|
import java.util.ArrayList;
|
23
|
import java.util.HashMap;
|
24
|
import java.util.List;
|
25
|
import java.util.Map;
|
26
|
|
27
|
import android.app.Activity;
|
28
|
import android.app.ListActivity;
|
29
|
import android.content.Intent;
|
30
|
import android.os.Bundle;
|
31
|
import android.util.SparseArray;
|
32
|
import android.view.View;
|
33
|
import android.widget.AdapterView;
|
34
|
import android.widget.AdapterView.OnItemClickListener;
|
35
|
import android.widget.SimpleAdapter;
|
36
|
|
37
|
import org.distorted.examples.aroundtheworld.AroundTheWorldActivity;
|
38
|
import org.distorted.examples.monalisa.MonaLisaActivity;
|
39
|
import org.distorted.examples.sink.SinkActivity;
|
40
|
import org.distorted.examples.fov.FOVActivity;
|
41
|
import org.distorted.examples.deform.DeformActivity;
|
42
|
import org.distorted.examples.listener.ListenerActivity;
|
43
|
import org.distorted.examples.dynamic.DynamicActivity;
|
44
|
import org.distorted.examples.girl.GirlActivity;
|
45
|
import org.distorted.examples.catanddog.CatAndDogActivity;
|
46
|
import org.distorted.examples.movingeffects.MovingEffectsActivity;
|
47
|
import org.distorted.examples.olimpic.OlimpicActivity;
|
48
|
import org.distorted.examples.differenteffects.DifferentEffectsActivity;
|
49
|
import org.distorted.examples.differentbitmaps.DifferentBitmapsActivity;
|
50
|
import org.distorted.examples.effectqueue.EffectQueueActivity;
|
51
|
import org.distorted.examples.check.CheckActivity;
|
52
|
import org.distorted.examples.bean.BeanActivity;
|
53
|
import org.distorted.examples.fbo.FBOActivity;
|
54
|
import org.distorted.examples.starwars.StarWarsActivity;
|
55
|
import org.distorted.examples.cubes.CubesActivity;
|
56
|
import org.distorted.examples.quaternion.QuaternionActivity;
|
57
|
import org.distorted.examples.matrix3d.Matrix3DActivity;
|
58
|
import org.distorted.examples.effects3d.Effects3DActivity;
|
59
|
import org.distorted.examples.plainmonalisa.PlainMonaLisaActivity;
|
60
|
import org.distorted.examples.save.SaveActivity;
|
61
|
import org.distorted.examples.flag.FlagActivity;
|
62
|
import org.distorted.examples.wind.WindActivity;
|
63
|
import org.distorted.examples.aroundtheworld.AroundTheWorldActivity;
|
64
|
|
65
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66
|
|
67
|
public class TableOfContents extends ListActivity
|
68
|
{
|
69
|
private static final String ITEM_IMAGE = "item_image";
|
70
|
private static final String ITEM_TITLE = "item_title";
|
71
|
private static final String ITEM_SUBTITLE = "item_subtitle";
|
72
|
|
73
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74
|
|
75
|
@Override
|
76
|
public void onCreate(Bundle savedInstanceState)
|
77
|
{
|
78
|
super.onCreate(savedInstanceState);
|
79
|
setContentView(R.layout.table_of_contents);
|
80
|
|
81
|
final List<Map<String, Object>> data = new ArrayList<>();
|
82
|
final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>();
|
83
|
|
84
|
int i = 0;
|
85
|
|
86
|
{
|
87
|
final Map<String, Object> item = new HashMap<>();
|
88
|
item.put(ITEM_IMAGE, R.drawable.icon_example_monalisa);
|
89
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_monalisa));
|
90
|
item.put(ITEM_SUBTITLE, getText(R.string.example_monalisa_subtitle));
|
91
|
data.add(item);
|
92
|
activityMapping.put(i++, MonaLisaActivity.class);
|
93
|
}
|
94
|
|
95
|
{
|
96
|
final Map<String, Object> item = new HashMap<>();
|
97
|
item.put(ITEM_IMAGE, R.drawable.icon_example_sink);
|
98
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_sink));
|
99
|
item.put(ITEM_SUBTITLE, getText(R.string.example_sink_subtitle));
|
100
|
data.add(item);
|
101
|
activityMapping.put(i++, SinkActivity.class);
|
102
|
}
|
103
|
|
104
|
{
|
105
|
final Map<String, Object> item = new HashMap<>();
|
106
|
item.put(ITEM_IMAGE, R.drawable.icon_example_bean);
|
107
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_bean));
|
108
|
item.put(ITEM_SUBTITLE, getText(R.string.example_bean_subtitle));
|
109
|
data.add(item);
|
110
|
activityMapping.put(i++, BeanActivity.class);
|
111
|
}
|
112
|
|
113
|
{
|
114
|
final Map<String, Object> item = new HashMap<>();
|
115
|
item.put(ITEM_IMAGE, R.drawable.icon_example_fov);
|
116
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_fov));
|
117
|
item.put(ITEM_SUBTITLE, getText(R.string.example_fov_subtitle));
|
118
|
data.add(item);
|
119
|
activityMapping.put(i++, FOVActivity.class);
|
120
|
}
|
121
|
|
122
|
{
|
123
|
final Map<String, Object> item = new HashMap<>();
|
124
|
item.put(ITEM_IMAGE, R.drawable.icon_example_deform);
|
125
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_deform));
|
126
|
item.put(ITEM_SUBTITLE, getText(R.string.example_deform_subtitle));
|
127
|
data.add(item);
|
128
|
activityMapping.put(i++, DeformActivity.class);
|
129
|
}
|
130
|
|
131
|
{
|
132
|
final Map<String, Object> item = new HashMap<>();
|
133
|
item.put(ITEM_IMAGE, R.drawable.icon_example_listener);
|
134
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_listener));
|
135
|
item.put(ITEM_SUBTITLE, getText(R.string.example_listener_subtitle));
|
136
|
data.add(item);
|
137
|
activityMapping.put(i++, ListenerActivity.class);
|
138
|
}
|
139
|
|
140
|
{
|
141
|
final Map<String, Object> item = new HashMap<>();
|
142
|
item.put(ITEM_IMAGE, R.drawable.icon_example_dynamic);
|
143
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_dynamic));
|
144
|
item.put(ITEM_SUBTITLE, getText(R.string.example_dynamic_subtitle));
|
145
|
data.add(item);
|
146
|
activityMapping.put(i++, DynamicActivity.class);
|
147
|
}
|
148
|
|
149
|
{
|
150
|
final Map<String, Object> item = new HashMap<>();
|
151
|
item.put(ITEM_IMAGE, R.drawable.icon_example_girl);
|
152
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_girl));
|
153
|
item.put(ITEM_SUBTITLE, getText(R.string.example_girl_subtitle));
|
154
|
data.add(item);
|
155
|
activityMapping.put(i++, GirlActivity.class);
|
156
|
}
|
157
|
|
158
|
{
|
159
|
final Map<String, Object> item = new HashMap<>();
|
160
|
item.put(ITEM_IMAGE, R.drawable.icon_example_macroblock);
|
161
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_macroblock));
|
162
|
item.put(ITEM_SUBTITLE, getText(R.string.example_macroblock_subtitle));
|
163
|
data.add(item);
|
164
|
activityMapping.put(i++, CatAndDogActivity.class);
|
165
|
}
|
166
|
|
167
|
{
|
168
|
final Map<String, Object> item = new HashMap<>();
|
169
|
item.put(ITEM_IMAGE, R.drawable.icon_example_movingeffects);
|
170
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_movingeffects));
|
171
|
item.put(ITEM_SUBTITLE, getText(R.string.example_movingeffects_subtitle));
|
172
|
data.add(item);
|
173
|
activityMapping.put(i++, MovingEffectsActivity.class);
|
174
|
}
|
175
|
|
176
|
{
|
177
|
final Map<String, Object> item = new HashMap<>();
|
178
|
item.put(ITEM_IMAGE, R.drawable.icon_example_differenteffects);
|
179
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_differenteffects));
|
180
|
item.put(ITEM_SUBTITLE, getText(R.string.example_differenteffects_subtitle));
|
181
|
data.add(item);
|
182
|
activityMapping.put(i++, DifferentEffectsActivity.class);
|
183
|
}
|
184
|
|
185
|
{
|
186
|
final Map<String, Object> item = new HashMap<>();
|
187
|
item.put(ITEM_IMAGE, R.drawable.icon_example_differentbitmaps);
|
188
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_differentbitmaps));
|
189
|
item.put(ITEM_SUBTITLE, getText(R.string.example_differentbitmaps_subtitle));
|
190
|
data.add(item);
|
191
|
activityMapping.put(i++, DifferentBitmapsActivity.class);
|
192
|
}
|
193
|
|
194
|
{
|
195
|
final Map<String, Object> item = new HashMap<>();
|
196
|
item.put(ITEM_IMAGE, R.drawable.icon_example_effectqueue);
|
197
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_effectqueue));
|
198
|
item.put(ITEM_SUBTITLE, getText(R.string.example_effectqueue_subtitle));
|
199
|
data.add(item);
|
200
|
activityMapping.put(i++, EffectQueueActivity.class);
|
201
|
}
|
202
|
|
203
|
{
|
204
|
final Map<String, Object> item = new HashMap<>();
|
205
|
item.put(ITEM_IMAGE, R.drawable.icon_example_check);
|
206
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_check));
|
207
|
item.put(ITEM_SUBTITLE, getText(R.string.example_check_subtitle));
|
208
|
data.add(item);
|
209
|
activityMapping.put(i++, CheckActivity.class);
|
210
|
}
|
211
|
|
212
|
{
|
213
|
final Map<String, Object> item = new HashMap<>();
|
214
|
item.put(ITEM_IMAGE, R.drawable.icon_example_fbo);
|
215
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_fbo));
|
216
|
item.put(ITEM_SUBTITLE, getText(R.string.example_fbo_subtitle));
|
217
|
data.add(item);
|
218
|
activityMapping.put(i++, FBOActivity.class);
|
219
|
}
|
220
|
|
221
|
{
|
222
|
final Map<String, Object> item = new HashMap<>();
|
223
|
item.put(ITEM_IMAGE, R.drawable.icon_example_starwars);
|
224
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_starwars));
|
225
|
item.put(ITEM_SUBTITLE, getText(R.string.example_starwars_subtitle));
|
226
|
data.add(item);
|
227
|
activityMapping.put(i++, StarWarsActivity.class);
|
228
|
}
|
229
|
|
230
|
{
|
231
|
final Map<String, Object> item = new HashMap<>();
|
232
|
item.put(ITEM_IMAGE, R.drawable.icon_example_olimpic);
|
233
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_olimpic));
|
234
|
item.put(ITEM_SUBTITLE, getText(R.string.example_olimpic_subtitle));
|
235
|
data.add(item);
|
236
|
activityMapping.put(i++, OlimpicActivity.class);
|
237
|
}
|
238
|
|
239
|
{
|
240
|
final Map<String, Object> item = new HashMap<>();
|
241
|
item.put(ITEM_IMAGE, R.drawable.icon_example_quaternion);
|
242
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_quaternion));
|
243
|
item.put(ITEM_SUBTITLE, getText(R.string.example_quaternion_subtitle));
|
244
|
data.add(item);
|
245
|
activityMapping.put(i++, QuaternionActivity.class);
|
246
|
}
|
247
|
|
248
|
{
|
249
|
final Map<String, Object> item = new HashMap<>();
|
250
|
item.put(ITEM_IMAGE, R.drawable.icon_example_cubes);
|
251
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_cubes));
|
252
|
item.put(ITEM_SUBTITLE, getText(R.string.example_cubes_subtitle));
|
253
|
data.add(item);
|
254
|
activityMapping.put(i++, CubesActivity.class);
|
255
|
}
|
256
|
|
257
|
{
|
258
|
final Map<String, Object> item = new HashMap<>();
|
259
|
item.put(ITEM_IMAGE, R.drawable.icon_example_matrix3d);
|
260
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_matrix3d));
|
261
|
item.put(ITEM_SUBTITLE, getText(R.string.example_matrix3d_subtitle));
|
262
|
data.add(item);
|
263
|
activityMapping.put(i++, Matrix3DActivity.class);
|
264
|
}
|
265
|
|
266
|
{
|
267
|
final Map<String, Object> item = new HashMap<>();
|
268
|
item.put(ITEM_IMAGE, R.drawable.icon_example_effects3d);
|
269
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_effects3d));
|
270
|
item.put(ITEM_SUBTITLE, getText(R.string.example_effects3d_subtitle));
|
271
|
data.add(item);
|
272
|
activityMapping.put(i++, Effects3DActivity.class);
|
273
|
}
|
274
|
|
275
|
{
|
276
|
final Map<String, Object> item = new HashMap<>();
|
277
|
item.put(ITEM_IMAGE, R.drawable.icon_example_monalisa);
|
278
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_plainmonalisa));
|
279
|
item.put(ITEM_SUBTITLE, getText(R.string.example_plainmonalisa_subtitle));
|
280
|
data.add(item);
|
281
|
activityMapping.put(i++, PlainMonaLisaActivity.class);
|
282
|
}
|
283
|
|
284
|
{
|
285
|
final Map<String, Object> item = new HashMap<>();
|
286
|
item.put(ITEM_IMAGE, R.drawable.icon_example_girl);
|
287
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_save));
|
288
|
item.put(ITEM_SUBTITLE, getText(R.string.example_save_subtitle));
|
289
|
data.add(item);
|
290
|
activityMapping.put(i++, SaveActivity.class);
|
291
|
}
|
292
|
|
293
|
{
|
294
|
final Map<String, Object> item = new HashMap<>();
|
295
|
item.put(ITEM_IMAGE, R.drawable.icon_example_flag);
|
296
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_flag));
|
297
|
item.put(ITEM_SUBTITLE, getText(R.string.example_flag_subtitle));
|
298
|
data.add(item);
|
299
|
activityMapping.put(i++, FlagActivity.class);
|
300
|
}
|
301
|
|
302
|
{
|
303
|
final Map<String, Object> item = new HashMap<>();
|
304
|
item.put(ITEM_IMAGE, R.drawable.icon_example_wind);
|
305
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_wind));
|
306
|
item.put(ITEM_SUBTITLE, getText(R.string.example_wind_subtitle));
|
307
|
data.add(item);
|
308
|
activityMapping.put(i++, WindActivity.class);
|
309
|
}
|
310
|
|
311
|
{
|
312
|
final Map<String, Object> item = new HashMap<>();
|
313
|
item.put(ITEM_IMAGE, R.drawable.icon_example_aroundtheworld);
|
314
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_aroundtheworld));
|
315
|
item.put(ITEM_SUBTITLE, getText(R.string.example_aroundtheworld_subtitle));
|
316
|
data.add(item);
|
317
|
activityMapping.put(i++, AroundTheWorldActivity.class);
|
318
|
}
|
319
|
|
320
|
final SimpleAdapter dataAdapter = new SimpleAdapter(this, data, R.layout.toc_item, new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE}, new int[] {R.id.Image, R.id.Title, R.id.SubTitle});
|
321
|
setListAdapter(dataAdapter);
|
322
|
|
323
|
getListView().setOnItemClickListener(new OnItemClickListener()
|
324
|
{
|
325
|
@Override
|
326
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
327
|
{
|
328
|
final Class<? extends Activity> activityToLaunch = activityMapping.get(position);
|
329
|
|
330
|
if (activityToLaunch != null)
|
331
|
{
|
332
|
final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch);
|
333
|
startActivity(launchIntent);
|
334
|
}
|
335
|
}
|
336
|
});
|
337
|
}
|
338
|
}
|
339
|
|
340
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|