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.deferredjob.DeferredJobActivity;
|
38
|
import org.distorted.examples.monalisa.MonaLisaActivity;
|
39
|
import org.distorted.examples.sink.SinkActivity;
|
40
|
import org.distorted.examples.projection.ProjectionActivity;
|
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.objecttree.ObjectTreeActivity;
|
54
|
import org.distorted.examples.starwars.StarWarsActivity;
|
55
|
import org.distorted.examples.inflate.InflateActivity;
|
56
|
import org.distorted.examples.quaternion.QuaternionActivity;
|
57
|
import org.distorted.examples.generic.GenericActivity;
|
58
|
import org.distorted.examples.surfaceview.SurfaceViewActivity;
|
59
|
import org.distorted.examples.save.SaveActivity;
|
60
|
import org.distorted.examples.flag.FlagActivity;
|
61
|
import org.distorted.examples.wind.WindActivity;
|
62
|
import org.distorted.examples.aroundtheworld.AroundTheWorldActivity;
|
63
|
import org.distorted.examples.mirror.MirrorActivity;
|
64
|
import org.distorted.examples.blur.BlurActivity;
|
65
|
import org.distorted.examples.multiblur.MultiblurActivity;
|
66
|
import org.distorted.examples.triblur.TriblurActivity;
|
67
|
import org.distorted.examples.transparency.TransparencyActivity;
|
68
|
import org.distorted.examples.postprocesstree.PostprocessTreeActivity;
|
69
|
import org.distorted.examples.stencil.StencilActivity;
|
70
|
import org.distorted.examples.glow.GlowActivity;
|
71
|
import org.distorted.examples.movingglow.MovingGlowActivity;
|
72
|
import org.distorted.examples.earth.EarthActivity;
|
73
|
import org.distorted.examples.rubik.RubikActivity;
|
74
|
import org.distorted.examples.meshjoin.MeshJoinActivity;
|
75
|
import org.distorted.examples.predeform.PredeformActivity;
|
76
|
import org.distorted.examples.singlemesh.SingleMeshActivity;
|
77
|
import org.distorted.examples.meshfile.MeshFileActivity;
|
78
|
|
79
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80
|
|
81
|
public class TableOfContents extends ListActivity
|
82
|
{
|
83
|
private static final String ITEM_IMAGE = "item_image";
|
84
|
private static final String ITEM_TITLE = "item_title";
|
85
|
private static final String ITEM_SUBTITLE = "item_subtitle";
|
86
|
|
87
|
private enum Application
|
88
|
{
|
89
|
MESHFILE (R.drawable.icon_example_meshfile , R.string.example_meshfile , R.string.example_meshfile_subtitle , MeshFileActivity.class),
|
90
|
|
91
|
|
92
|
MONALISA (R.drawable.icon_example_monalisa , R.string.example_monalisa , R.string.example_monalisa_subtitle , MonaLisaActivity.class),
|
93
|
SINK (R.drawable.icon_example_sink , R.string.example_sink , R.string.example_sink_subtitle , SinkActivity.class),
|
94
|
BEAN (R.drawable.icon_example_bean , R.string.example_bean , R.string.example_bean_subtitle , BeanActivity.class),
|
95
|
PROJECTION (R.drawable.icon_example_projection , R.string.example_projection , R.string.example_projection_subtitle , ProjectionActivity.class),
|
96
|
DEFORM (R.drawable.icon_example_deform , R.string.example_deform , R.string.example_deform_subtitle , DeformActivity.class),
|
97
|
LISTENER (R.drawable.icon_example_listener , R.string.example_listener , R.string.example_listener_subtitle , ListenerActivity.class),
|
98
|
DYNAMIC (R.drawable.icon_example_dynamic , R.string.example_dynamic , R.string.example_dynamic_subtitle , DynamicActivity.class),
|
99
|
GIRL (R.drawable.icon_example_girl , R.string.example_girl , R.string.example_girl_subtitle , GirlActivity.class),
|
100
|
CATANDDOG (R.drawable.icon_example_catanddog , R.string.example_catanddog , R.string.example_catanddog_subtitle , CatAndDogActivity.class),
|
101
|
MOVINGEFFECTS (R.drawable.icon_example_movingeffects , R.string.example_movingeffects , R.string.example_movingeffects_subtitle , MovingEffectsActivity.class),
|
102
|
DIFFERENTEFFECTS (R.drawable.icon_example_differenteffects, R.string.example_differenteffects, R.string.example_differenteffects_subtitle, DifferentEffectsActivity.class),
|
103
|
DIFFERENTBITMAPS (R.drawable.icon_example_differentbitmaps, R.string.example_differentbitmaps, R.string.example_differentbitmaps_subtitle, DifferentBitmapsActivity.class),
|
104
|
EFFECTQUEUE (R.drawable.icon_example_effectqueue , R.string.example_effectqueue , R.string.example_effectqueue_subtitle , EffectQueueActivity.class),
|
105
|
CHECK (R.drawable.icon_example_check , R.string.example_check , R.string.example_check_subtitle , CheckActivity.class),
|
106
|
OBJECTTREE (R.drawable.icon_example_objecttree , R.string.example_objecttree , R.string.example_objecttree_subtitle , ObjectTreeActivity.class),
|
107
|
STARWARS (R.drawable.icon_example_starwars , R.string.example_starwars , R.string.example_starwars_subtitle , StarWarsActivity.class),
|
108
|
OLIMPIC (R.drawable.icon_example_olimpic , R.string.example_olimpic , R.string.example_olimpic_subtitle , OlimpicActivity.class),
|
109
|
QUATERNION (R.drawable.icon_example_quaternion , R.string.example_quaternion , R.string.example_quaternion_subtitle , QuaternionActivity.class),
|
110
|
INFLATE (R.drawable.icon_example_inflate , R.string.example_inflate , R.string.example_inflate_subtitle , InflateActivity.class),
|
111
|
GENERIC (R.drawable.icon_example_generic , R.string.example_generic , R.string.example_generic_subtitle , GenericActivity.class),
|
112
|
SURFACEVIEW (R.drawable.icon_example_monalisa , R.string.example_surfaceview , R.string.example_surfaceview_subtitle , SurfaceViewActivity.class),
|
113
|
SAVE (R.drawable.icon_example_save , R.string.example_save , R.string.example_save_subtitle , SaveActivity.class),
|
114
|
FLAG (R.drawable.icon_example_flag , R.string.example_flag , R.string.example_flag_subtitle , FlagActivity.class),
|
115
|
WIND (R.drawable.icon_example_wind , R.string.example_wind , R.string.example_wind_subtitle , WindActivity.class),
|
116
|
AROUNDTHEWORLD (R.drawable.icon_example_aroundtheworld , R.string.example_aroundtheworld , R.string.example_aroundtheworld_subtitle , AroundTheWorldActivity.class),
|
117
|
MIRROR (R.drawable.icon_example_mirror , R.string.example_mirror , R.string.example_mirror_subtitle , MirrorActivity.class),
|
118
|
STENCIL (R.drawable.icon_example_stencil , R.string.example_stencil , R.string.example_stencil_subtitle , StencilActivity.class),
|
119
|
BLUR (R.drawable.icon_example_blur , R.string.example_blur , R.string.example_blur_subtitle , BlurActivity.class),
|
120
|
MULTIBLUR (R.drawable.icon_example_multiblur , R.string.example_multiblur , R.string.example_multiblur_subtitle , MultiblurActivity.class),
|
121
|
TRIBLUR (R.drawable.icon_example_triblur , R.string.example_triblur , R.string.example_triblur_subtitle , TriblurActivity.class),
|
122
|
TRANSPARENCY (R.drawable.icon_example_transparency , R.string.example_transparency , R.string.example_transparency_subtitle , TransparencyActivity.class),
|
123
|
POSTPROCESSTREE (R.drawable.icon_example_postprocesstree , R.string.example_postprocesstree , R.string.example_postprocesstree_subtitle , PostprocessTreeActivity.class),
|
124
|
GLOW (R.drawable.icon_example_glow , R.string.example_glow , R.string.example_glow_subtitle , GlowActivity.class),
|
125
|
MOVINGGLOW (R.drawable.icon_example_movingglow , R.string.example_moving_glow , R.string.example_moving_glow_subtitle , MovingGlowActivity.class),
|
126
|
EARTH (R.drawable.icon_example_earth , R.string.example_earth , R.string.example_earth_subtitle , EarthActivity.class),
|
127
|
RUBIK (R.drawable.icon_example_rubik , R.string.example_rubik , R.string.example_rubik_subtitle , RubikActivity.class),
|
128
|
MESHJOIN (R.drawable.icon_example_meshjoin , R.string.example_meshjoin , R.string.example_meshjoin_subtitle , MeshJoinActivity.class),
|
129
|
PREDEFORM (R.drawable.icon_example_predeform , R.string.example_predeform , R.string.example_predeform_subtitle , PredeformActivity.class),
|
130
|
DEFERREDJOB (R.drawable.icon_example_deferredjob , R.string.example_deferredjob , R.string.example_deferredjob_subtitle , DeferredJobActivity.class),
|
131
|
SINGLEMESH (R.drawable.icon_example_singlemesh , R.string.example_singlemesh , R.string.example_singlemesh_subtitle , SingleMeshActivity.class),
|
132
|
;
|
133
|
|
134
|
final int icon, title, subtitle;
|
135
|
final Class<? extends Activity> activity;
|
136
|
|
137
|
Application(int i, int t, int s, Class<? extends Activity> a)
|
138
|
{
|
139
|
icon = i;
|
140
|
title = t;
|
141
|
subtitle = s;
|
142
|
activity = a;
|
143
|
}
|
144
|
}
|
145
|
|
146
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
147
|
|
148
|
@Override
|
149
|
public void onCreate(Bundle savedInstanceState)
|
150
|
{
|
151
|
super.onCreate(savedInstanceState);
|
152
|
setContentView(R.layout.table_of_contents);
|
153
|
|
154
|
final List<Map<String, Object>> data = new ArrayList<>();
|
155
|
final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>();
|
156
|
|
157
|
int index=0;
|
158
|
|
159
|
for( Application app : Application.values() )
|
160
|
{
|
161
|
final Map<String, Object> item = new HashMap<>();
|
162
|
item.put(ITEM_IMAGE, app.icon);
|
163
|
item.put(ITEM_TITLE, (index+1)+". "+getText(app.title));
|
164
|
item.put(ITEM_SUBTITLE, getText(app.subtitle));
|
165
|
data.add(item);
|
166
|
activityMapping.put(index++, app.activity);
|
167
|
}
|
168
|
|
169
|
final SimpleAdapter dataAdapter = new SimpleAdapter( this,
|
170
|
data,
|
171
|
R.layout.toc_item,
|
172
|
new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE},
|
173
|
new int[] {R.id.Image, R.id.Title, R.id.SubTitle} );
|
174
|
setListAdapter(dataAdapter);
|
175
|
|
176
|
getListView().setOnItemClickListener(new OnItemClickListener()
|
177
|
{
|
178
|
@Override
|
179
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
180
|
{
|
181
|
final Class<? extends Activity> activityToLaunch = activityMapping.get(position);
|
182
|
|
183
|
if (activityToLaunch != null)
|
184
|
{
|
185
|
final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch);
|
186
|
startActivity(launchIntent);
|
187
|
}
|
188
|
}
|
189
|
});
|
190
|
}
|
191
|
}
|