Project

General

Profile

Download (18.1 KB) Statistics
| Branch: | Revision:

examples / src / main / java / org / distorted / examples / TableOfContents.java @ 77a500b3

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.monalisa.MonaLisaActivity;
38
import org.distorted.examples.sink.SinkActivity;
39
import org.distorted.examples.projection.ProjectionActivity;
40
import org.distorted.examples.deform.DeformActivity;
41
import org.distorted.examples.listener.ListenerActivity;
42
import org.distorted.examples.dynamic.DynamicActivity;
43
import org.distorted.examples.girl.GirlActivity;
44
import org.distorted.examples.catanddog.CatAndDogActivity;
45
import org.distorted.examples.movingeffects.MovingEffectsActivity;
46
import org.distorted.examples.olimpic.OlimpicActivity;
47
import org.distorted.examples.differenteffects.DifferentEffectsActivity;
48
import org.distorted.examples.differentbitmaps.DifferentBitmapsActivity;
49
import org.distorted.examples.effectqueue.EffectQueueActivity;
50
import org.distorted.examples.check.CheckActivity;
51
import org.distorted.examples.bean.BeanActivity;
52
import org.distorted.examples.bitmaptree.BitmapTreeActivity;
53
import org.distorted.examples.starwars.StarWarsActivity;
54
import org.distorted.examples.cubes.CubesActivity;
55
import org.distorted.examples.quaternion.QuaternionActivity;
56
import org.distorted.examples.effects3d.Effects3DActivity;
57
import org.distorted.examples.plainmonalisa.PlainMonaLisaActivity;
58
import org.distorted.examples.save.SaveActivity;
59
import org.distorted.examples.flag.FlagActivity;
60
import org.distorted.examples.wind.WindActivity;
61
import org.distorted.examples.aroundtheworld.AroundTheWorldActivity;
62
import org.distorted.examples.mirror.MirrorActivity;
63
import org.distorted.examples.blur.BlurActivity;
64
import org.distorted.examples.multiblur.MultiblurActivity;
65
import org.distorted.examples.triblur.TriblurActivity;
66
import org.distorted.examples.transparency.TransparencyActivity;
67
import org.distorted.examples.postprocesstree.PostprocessTreeActivity;
68
import org.distorted.examples.stencil.StencilActivity;
69
import org.distorted.examples.glow.GlowActivity;
70
import org.distorted.examples.movingglow.MovingGlowActivity;
71
import org.distorted.examples.inflate.InflateActivity;
72

    
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

    
75
public class TableOfContents extends ListActivity 
76
  {
77
  private static final String ITEM_IMAGE = "item_image";
78
  private static final String ITEM_TITLE = "item_title";
79
  private static final String ITEM_SUBTITLE = "item_subtitle"; 
80

    
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
   
83
  @Override
84
  public void onCreate(Bundle savedInstanceState) 
85
   {
86
   super.onCreate(savedInstanceState);
87
   setContentView(R.layout.table_of_contents);
88
      
89
   final List<Map<String, Object>> data = new ArrayList<>();
90
   final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>();
91
      
92
   int i = 0;
93

    
94
   {
95
      final Map<String, Object> item = new HashMap<>();
96
      item.put(ITEM_IMAGE, R.drawable.icon_example_monalisa);
97
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_monalisa));
98
      item.put(ITEM_SUBTITLE, getText(R.string.example_monalisa_subtitle));
99
      data.add(item);
100
      activityMapping.put(i++, MonaLisaActivity.class);        
101
   }
102
      
103
   {
104
      final Map<String, Object> item = new HashMap<>();
105
      item.put(ITEM_IMAGE, R.drawable.icon_example_sink);
106
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_sink));
107
      item.put(ITEM_SUBTITLE, getText(R.string.example_sink_subtitle));
108
      data.add(item);
109
      activityMapping.put(i++, SinkActivity.class);
110
   }
111
   
112
   {
113
      final Map<String, Object> item = new HashMap<>();
114
      item.put(ITEM_IMAGE, R.drawable.icon_example_bean);
115
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_bean));
116
      item.put(ITEM_SUBTITLE, getText(R.string.example_bean_subtitle));
117
      data.add(item);
118
      activityMapping.put(i++, BeanActivity.class);
119
   }
120
   
121
   {
122
      final Map<String, Object> item = new HashMap<>();
123
      item.put(ITEM_IMAGE, R.drawable.icon_example_projection);
124
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_projection));
125
      item.put(ITEM_SUBTITLE, getText(R.string.example_projection_subtitle));
126
      data.add(item);
127
      activityMapping.put(i++, ProjectionActivity.class);
128
   }
129
         
130
   {
131
      final Map<String, Object> item = new HashMap<>();
132
      item.put(ITEM_IMAGE, R.drawable.icon_example_deform);
133
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_deform));
134
      item.put(ITEM_SUBTITLE, getText(R.string.example_deform_subtitle));
135
      data.add(item);
136
      activityMapping.put(i++, DeformActivity.class);
137
   }
138
  
139
   {
140
      final Map<String, Object> item = new HashMap<>();
141
      item.put(ITEM_IMAGE, R.drawable.icon_example_listener);
142
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_listener));
143
      item.put(ITEM_SUBTITLE, getText(R.string.example_listener_subtitle));
144
      data.add(item);
145
      activityMapping.put(i++, ListenerActivity.class);
146
   }
147
   
148
   {
149
      final Map<String, Object> item = new HashMap<>();
150
      item.put(ITEM_IMAGE, R.drawable.icon_example_dynamic);
151
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_dynamic));
152
      item.put(ITEM_SUBTITLE, getText(R.string.example_dynamic_subtitle));
153
      data.add(item);
154
      activityMapping.put(i++, DynamicActivity.class);
155
   }
156
   
157
   {
158
      final Map<String, Object> item = new HashMap<>();
159
      item.put(ITEM_IMAGE, R.drawable.icon_example_girl);
160
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_girl));
161
      item.put(ITEM_SUBTITLE, getText(R.string.example_girl_subtitle));
162
      data.add(item);
163
      activityMapping.put(i++, GirlActivity.class);
164
   }
165
   
166
   {
167
      final Map<String, Object> item = new HashMap<>();
168
      item.put(ITEM_IMAGE, R.drawable.icon_example_macroblock);
169
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_macroblock));
170
      item.put(ITEM_SUBTITLE, getText(R.string.example_macroblock_subtitle));
171
      data.add(item);
172
      activityMapping.put(i++, CatAndDogActivity.class);
173
   }
174
   
175
   {
176
      final Map<String, Object> item = new HashMap<>();
177
      item.put(ITEM_IMAGE, R.drawable.icon_example_movingeffects);
178
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_movingeffects));
179
      item.put(ITEM_SUBTITLE, getText(R.string.example_movingeffects_subtitle));
180
      data.add(item);
181
      activityMapping.put(i++, MovingEffectsActivity.class);
182
   }
183
   
184
   {
185
      final Map<String, Object> item = new HashMap<>();
186
      item.put(ITEM_IMAGE, R.drawable.icon_example_differenteffects);
187
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_differenteffects));
188
      item.put(ITEM_SUBTITLE, getText(R.string.example_differenteffects_subtitle));
189
      data.add(item);
190
      activityMapping.put(i++, DifferentEffectsActivity.class);
191
   }
192
   
193
   {
194
      final Map<String, Object> item = new HashMap<>();
195
      item.put(ITEM_IMAGE, R.drawable.icon_example_differentbitmaps);
196
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_differentbitmaps));
197
      item.put(ITEM_SUBTITLE, getText(R.string.example_differentbitmaps_subtitle));
198
      data.add(item);
199
      activityMapping.put(i++, DifferentBitmapsActivity.class);
200
   }
201
   
202
   {
203
      final Map<String, Object> item = new HashMap<>();
204
      item.put(ITEM_IMAGE, R.drawable.icon_example_effectqueue);
205
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_effectqueue));
206
      item.put(ITEM_SUBTITLE, getText(R.string.example_effectqueue_subtitle));
207
      data.add(item);
208
      activityMapping.put(i++, EffectQueueActivity.class);
209
   }
210
   
211
   {
212
      final Map<String, Object> item = new HashMap<>();
213
      item.put(ITEM_IMAGE, R.drawable.icon_example_check);
214
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_check));
215
      item.put(ITEM_SUBTITLE, getText(R.string.example_check_subtitle));
216
      data.add(item);
217
      activityMapping.put(i++, CheckActivity.class);
218
   }
219
   
220
   {
221
      final Map<String, Object> item = new HashMap<>();
222
      item.put(ITEM_IMAGE, R.drawable.icon_example_fbo);
223
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_bitmaptree));
224
      item.put(ITEM_SUBTITLE, getText(R.string.example_bitmaptree_subtitle));
225
      data.add(item);
226
      activityMapping.put(i++, BitmapTreeActivity.class);
227
   }
228
      
229
   {
230
      final Map<String, Object> item = new HashMap<>();
231
      item.put(ITEM_IMAGE, R.drawable.icon_example_starwars);
232
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_starwars));
233
      item.put(ITEM_SUBTITLE, getText(R.string.example_starwars_subtitle));
234
      data.add(item);
235
      activityMapping.put(i++, StarWarsActivity.class);
236
   }
237
         
238
   {
239
      final Map<String, Object> item = new HashMap<>();
240
      item.put(ITEM_IMAGE, R.drawable.icon_example_olimpic);
241
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_olimpic));
242
      item.put(ITEM_SUBTITLE, getText(R.string.example_olimpic_subtitle));
243
      data.add(item);
244
      activityMapping.put(i++, OlimpicActivity.class);
245
   }
246
   
247
   {
248
      final Map<String, Object> item = new HashMap<>();
249
      item.put(ITEM_IMAGE, R.drawable.icon_example_quaternion);
250
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_quaternion));
251
      item.put(ITEM_SUBTITLE, getText(R.string.example_quaternion_subtitle));
252
      data.add(item);
253
      activityMapping.put(i++, QuaternionActivity.class);
254
   }
255
   
256
   {
257
      final Map<String, Object> item = new HashMap<>();
258
      item.put(ITEM_IMAGE, R.drawable.icon_example_cubes);
259
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_cubes));
260
      item.put(ITEM_SUBTITLE, getText(R.string.example_cubes_subtitle));
261
      data.add(item);
262
      activityMapping.put(i++, CubesActivity.class);
263
   }
264

    
265
   {
266
      final Map<String, Object> item = new HashMap<>();
267
      item.put(ITEM_IMAGE, R.drawable.icon_example_effects3d);
268
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_effects3d));
269
      item.put(ITEM_SUBTITLE, getText(R.string.example_effects3d_subtitle));
270
      data.add(item);
271
      activityMapping.put(i++, Effects3DActivity.class);
272
   }
273

    
274
   {
275
      final Map<String, Object> item = new HashMap<>();
276
      item.put(ITEM_IMAGE, R.drawable.icon_example_monalisa);
277
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_plainmonalisa));
278
      item.put(ITEM_SUBTITLE, getText(R.string.example_plainmonalisa_subtitle));
279
      data.add(item);
280
      activityMapping.put(i++, PlainMonaLisaActivity.class);
281
   }
282

    
283
   {
284
      final Map<String, Object> item = new HashMap<>();
285
      item.put(ITEM_IMAGE, R.drawable.icon_example_girl);
286
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_save));
287
      item.put(ITEM_SUBTITLE, getText(R.string.example_save_subtitle));
288
      data.add(item);
289
      activityMapping.put(i++, SaveActivity.class);
290
   }
291

    
292
   {
293
      final Map<String, Object> item = new HashMap<>();
294
      item.put(ITEM_IMAGE, R.drawable.icon_example_flag);
295
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_flag));
296
      item.put(ITEM_SUBTITLE, getText(R.string.example_flag_subtitle));
297
      data.add(item);
298
      activityMapping.put(i++, FlagActivity.class);
299
   }
300

    
301
   {
302
      final Map<String, Object> item = new HashMap<>();
303
      item.put(ITEM_IMAGE, R.drawable.icon_example_wind);
304
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_wind));
305
      item.put(ITEM_SUBTITLE, getText(R.string.example_wind_subtitle));
306
      data.add(item);
307
      activityMapping.put(i++, WindActivity.class);
308
   }
309

    
310
   {
311
      final Map<String, Object> item = new HashMap<>();
312
      item.put(ITEM_IMAGE, R.drawable.icon_example_aroundtheworld);
313
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_aroundtheworld));
314
      item.put(ITEM_SUBTITLE, getText(R.string.example_aroundtheworld_subtitle));
315
      data.add(item);
316
      activityMapping.put(i++, AroundTheWorldActivity.class);
317
   }
318

    
319
   {
320
      final Map<String, Object> item = new HashMap<>();
321
      item.put(ITEM_IMAGE, R.drawable.icon_example_mirror);
322
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_mirror));
323
      item.put(ITEM_SUBTITLE, getText(R.string.example_mirror_subtitle));
324
      data.add(item);
325
      activityMapping.put(i++, MirrorActivity.class);
326
   }
327

    
328
   {
329
      final Map<String, Object> item = new HashMap<>();
330
      item.put(ITEM_IMAGE, R.drawable.icon_example_stencil);
331
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_stencil));
332
      item.put(ITEM_SUBTITLE, getText(R.string.example_stencil_subtitle));
333
      data.add(item);
334
      activityMapping.put(i++, StencilActivity.class);
335
   }
336

    
337
   {
338
      final Map<String, Object> item = new HashMap<>();
339
      item.put(ITEM_IMAGE, R.drawable.icon_example_blur);
340
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_blur));
341
      item.put(ITEM_SUBTITLE, getText(R.string.example_blur_subtitle));
342
      data.add(item);
343
      activityMapping.put(i++, BlurActivity.class);
344
   }
345

    
346
   {
347
      final Map<String, Object> item = new HashMap<>();
348
      item.put(ITEM_IMAGE, R.drawable.icon_example_multiblur);
349
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_multiblur));
350
      item.put(ITEM_SUBTITLE, getText(R.string.example_multiblur_subtitle));
351
      data.add(item);
352
      activityMapping.put(i++, MultiblurActivity.class);
353
   }
354

    
355
   {
356
      final Map<String, Object> item = new HashMap<>();
357
      item.put(ITEM_IMAGE, R.drawable.icon_example_triblur);
358
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_triblur));
359
      item.put(ITEM_SUBTITLE, getText(R.string.example_triblur_subtitle));
360
      data.add(item);
361
      activityMapping.put(i++, TriblurActivity.class);
362
   }
363

    
364
   {
365
      final Map<String, Object> item = new HashMap<>();
366
      item.put(ITEM_IMAGE, R.drawable.icon_example_transparency);
367
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_transparency));
368
      item.put(ITEM_SUBTITLE, getText(R.string.example_transparency_subtitle));
369
      data.add(item);
370
      activityMapping.put(i++, TransparencyActivity.class);
371
   }
372

    
373
   {
374
      final Map<String, Object> item = new HashMap<>();
375
      item.put(ITEM_IMAGE, R.drawable.icon_example_postprocesstree);
376
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_postprocesstree));
377
      item.put(ITEM_SUBTITLE, getText(R.string.example_postprocesstree_subtitle));
378
      data.add(item);
379
      activityMapping.put(i++, PostprocessTreeActivity.class);
380
   }
381

    
382
   {
383
      final Map<String, Object> item = new HashMap<>();
384
      item.put(ITEM_IMAGE, R.drawable.icon_example_wip);
385
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_glow));
386
      item.put(ITEM_SUBTITLE, getText(R.string.example_glow_subtitle));
387
      data.add(item);
388
      activityMapping.put(i++, GlowActivity.class);
389
   }
390

    
391
   {
392
      final Map<String, Object> item = new HashMap<>();
393
      item.put(ITEM_IMAGE, R.drawable.icon_example_movingglow);
394
      item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_moving_glow));
395
      item.put(ITEM_SUBTITLE, getText(R.string.example_moving_glow_subtitle));
396
      data.add(item);
397
      activityMapping.put(i++, MovingGlowActivity.class);
398
   }
399

    
400
   {
401
   final Map<String, Object> item = new HashMap<>();
402
   item.put(ITEM_IMAGE, R.drawable.icon_example_wip);
403
   item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_inflate));
404
   item.put(ITEM_SUBTITLE, getText(R.string.example_inflate_subtitle));
405
   data.add(item);
406
   activityMapping.put(i++, InflateActivity.class);
407
   }
408

    
409
   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});
410
   setListAdapter(dataAdapter);  
411
      
412
   getListView().setOnItemClickListener(new OnItemClickListener() 
413
     {
414
     @Override
415
     public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
416
      {
417
      final Class<? extends Activity> activityToLaunch = activityMapping.get(position);
418
            
419
      if (activityToLaunch != null)
420
        {
421
        final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch);
422
        startActivity(launchIntent);
423
        }            
424
      }
425
     });
426
   }  
427
  }
428

    
429
///////////////////////////////////////////////////////////////////////////////////////////////////
    (1-1/1)