Project

General

Profile

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

examples / src / main / java / org / distorted / examples / TableOfContents.java @ 65f622c1

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

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
399
   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});
400
   setListAdapter(dataAdapter);  
401
      
402
   getListView().setOnItemClickListener(new OnItemClickListener() 
403
     {
404
     @Override
405
     public void onItemClick(AdapterView<?> parent, View view, int position, long id) 
406
      {
407
      final Class<? extends Activity> activityToLaunch = activityMapping.get(position);
408
            
409
      if (activityToLaunch != null)
410
        {
411
        final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch);
412
        startActivity(launchIntent);
413
        }            
414
      }
415
     });
416
   }  
417
  }
418

    
419
///////////////////////////////////////////////////////////////////////////////////////////////////
    (1-1/1)