1 |
bc0a685b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
5068fa06
|
Leszek Koltunski
|
package org.distorted.examples;
|
21 |
427ab7bf
|
Leszek Koltunski
|
|
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 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.monalisa.MonaLisaActivity;
|
38 |
|
|
import org.distorted.examples.sink.SinkActivity;
|
39 |
|
|
import org.distorted.examples.fov.FOVActivity;
|
40 |
|
|
import org.distorted.examples.deform.DeformActivity;
|
41 |
|
|
import org.distorted.examples.listener.ListenerActivity;
|
42 |
f988589e
|
Leszek Koltunski
|
import org.distorted.examples.dynamic.DynamicActivity;
|
43 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.girl.GirlActivity;
|
44 |
f26ab2fd
|
Leszek Koltunski
|
import org.distorted.examples.catanddog.CatAndDogActivity;
|
45 |
5068fa06
|
Leszek Koltunski
|
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 |
e5424523
|
Leszek Koltunski
|
import org.distorted.examples.effects2d.Effects2DActivity;
|
50 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.check.CheckActivity;
|
51 |
|
|
import org.distorted.examples.bean.BeanActivity;
|
52 |
|
|
import org.distorted.examples.fbo.FBOActivity;
|
53 |
|
|
import org.distorted.examples.starwars.StarWarsActivity;
|
54 |
|
|
import org.distorted.examples.cubes.CubesActivity;
|
55 |
|
|
import org.distorted.examples.quaternion.QuaternionActivity;
|
56 |
db5d943e
|
Leszek Koltunski
|
import org.distorted.examples.matrix3d.Matrix3DActivity;
|
57 |
76a81b6a
|
Leszek Koltunski
|
import org.distorted.examples.effects3d.Effects3DActivity;
|
58 |
862fcd79
|
Leszek Koltunski
|
import org.distorted.examples.plainmonalisa.PlainMonaLisaActivity;
|
59 |
a2cb31e9
|
Leszek Koltunski
|
import org.distorted.examples.save.SaveActivity;
|
60 |
175f355d
|
Leszek Koltunski
|
import org.distorted.examples.flag.FlagActivity;
|
61 |
427ab7bf
|
Leszek Koltunski
|
|
62 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
63 |
|
|
|
64 |
|
|
public class TableOfContents extends ListActivity
|
65 |
|
|
{
|
66 |
|
|
private static final String ITEM_IMAGE = "item_image";
|
67 |
|
|
private static final String ITEM_TITLE = "item_title";
|
68 |
|
|
private static final String ITEM_SUBTITLE = "item_subtitle";
|
69 |
|
|
|
70 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71 |
|
|
|
72 |
|
|
@Override
|
73 |
|
|
public void onCreate(Bundle savedInstanceState)
|
74 |
|
|
{
|
75 |
|
|
super.onCreate(savedInstanceState);
|
76 |
|
|
setContentView(R.layout.table_of_contents);
|
77 |
|
|
|
78 |
a2cb31e9
|
Leszek Koltunski
|
final List<Map<String, Object>> data = new ArrayList<>();
|
79 |
|
|
final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>();
|
80 |
427ab7bf
|
Leszek Koltunski
|
|
81 |
|
|
int i = 0;
|
82 |
|
|
|
83 |
|
|
{
|
84 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
85 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_monalisa);
|
86 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_monalisa));
|
87 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_monalisa_subtitle));
|
88 |
|
|
data.add(item);
|
89 |
|
|
activityMapping.put(i++, MonaLisaActivity.class);
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
{
|
93 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
94 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_sink);
|
95 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_sink));
|
96 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_sink_subtitle));
|
97 |
|
|
data.add(item);
|
98 |
|
|
activityMapping.put(i++, SinkActivity.class);
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
{
|
102 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
103 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_bean);
|
104 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_bean));
|
105 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_bean_subtitle));
|
106 |
|
|
data.add(item);
|
107 |
|
|
activityMapping.put(i++, BeanActivity.class);
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
{
|
111 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
112 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_fov);
|
113 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_fov));
|
114 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_fov_subtitle));
|
115 |
|
|
data.add(item);
|
116 |
|
|
activityMapping.put(i++, FOVActivity.class);
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
{
|
120 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
121 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_deform);
|
122 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_deform));
|
123 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_deform_subtitle));
|
124 |
|
|
data.add(item);
|
125 |
|
|
activityMapping.put(i++, DeformActivity.class);
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
{
|
129 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
130 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_listener);
|
131 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_listener));
|
132 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_listener_subtitle));
|
133 |
|
|
data.add(item);
|
134 |
|
|
activityMapping.put(i++, ListenerActivity.class);
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
{
|
138 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
139 |
f988589e
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_dynamic);
|
140 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_dynamic));
|
141 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_dynamic_subtitle));
|
142 |
427ab7bf
|
Leszek Koltunski
|
data.add(item);
|
143 |
f988589e
|
Leszek Koltunski
|
activityMapping.put(i++, DynamicActivity.class);
|
144 |
427ab7bf
|
Leszek Koltunski
|
}
|
145 |
|
|
|
146 |
|
|
{
|
147 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
148 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_girl);
|
149 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_girl));
|
150 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_girl_subtitle));
|
151 |
|
|
data.add(item);
|
152 |
|
|
activityMapping.put(i++, GirlActivity.class);
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
{
|
156 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
157 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_macroblock);
|
158 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_macroblock));
|
159 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_macroblock_subtitle));
|
160 |
|
|
data.add(item);
|
161 |
f26ab2fd
|
Leszek Koltunski
|
activityMapping.put(i++, CatAndDogActivity.class);
|
162 |
427ab7bf
|
Leszek Koltunski
|
}
|
163 |
|
|
|
164 |
|
|
{
|
165 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
166 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_movingeffects);
|
167 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_movingeffects));
|
168 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_movingeffects_subtitle));
|
169 |
|
|
data.add(item);
|
170 |
|
|
activityMapping.put(i++, MovingEffectsActivity.class);
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
{
|
174 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
175 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_differenteffects);
|
176 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_differenteffects));
|
177 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_differenteffects_subtitle));
|
178 |
|
|
data.add(item);
|
179 |
|
|
activityMapping.put(i++, DifferentEffectsActivity.class);
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
{
|
183 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
184 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_differentbitmaps);
|
185 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_differentbitmaps));
|
186 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_differentbitmaps_subtitle));
|
187 |
|
|
data.add(item);
|
188 |
|
|
activityMapping.put(i++, DifferentBitmapsActivity.class);
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
{
|
192 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
193 |
e5424523
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_effects2d);
|
194 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_effects2d));
|
195 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_effects2d_subtitle));
|
196 |
427ab7bf
|
Leszek Koltunski
|
data.add(item);
|
197 |
e5424523
|
Leszek Koltunski
|
activityMapping.put(i++, Effects2DActivity.class);
|
198 |
427ab7bf
|
Leszek Koltunski
|
}
|
199 |
|
|
|
200 |
|
|
{
|
201 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
202 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_check);
|
203 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_check));
|
204 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_check_subtitle));
|
205 |
|
|
data.add(item);
|
206 |
|
|
activityMapping.put(i++, CheckActivity.class);
|
207 |
|
|
}
|
208 |
|
|
|
209 |
|
|
{
|
210 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
211 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_fbo);
|
212 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_fbo));
|
213 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_fbo_subtitle));
|
214 |
|
|
data.add(item);
|
215 |
|
|
activityMapping.put(i++, FBOActivity.class);
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
{
|
219 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
220 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_starwars);
|
221 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_starwars));
|
222 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_starwars_subtitle));
|
223 |
|
|
data.add(item);
|
224 |
|
|
activityMapping.put(i++, StarWarsActivity.class);
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
{
|
228 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
229 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_olimpic);
|
230 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_olimpic));
|
231 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_olimpic_subtitle));
|
232 |
|
|
data.add(item);
|
233 |
|
|
activityMapping.put(i++, OlimpicActivity.class);
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
{
|
237 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
238 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_quaternion);
|
239 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_quaternion));
|
240 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_quaternion_subtitle));
|
241 |
|
|
data.add(item);
|
242 |
|
|
activityMapping.put(i++, QuaternionActivity.class);
|
243 |
|
|
}
|
244 |
|
|
|
245 |
|
|
{
|
246 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
247 |
427ab7bf
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_cubes);
|
248 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_cubes));
|
249 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_cubes_subtitle));
|
250 |
|
|
data.add(item);
|
251 |
|
|
activityMapping.put(i++, CubesActivity.class);
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
{
|
255 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
256 |
db5d943e
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_matrix3d);
|
257 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_matrix3d));
|
258 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_matrix3d_subtitle));
|
259 |
427ab7bf
|
Leszek Koltunski
|
data.add(item);
|
260 |
db5d943e
|
Leszek Koltunski
|
activityMapping.put(i++, Matrix3DActivity.class);
|
261 |
427ab7bf
|
Leszek Koltunski
|
}
|
262 |
862fcd79
|
Leszek Koltunski
|
|
263 |
08f92d82
|
Leszek Koltunski
|
{
|
264 |
|
|
final Map<String, Object> item = new HashMap<>();
|
265 |
76a81b6a
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_effects3d);
|
266 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_effects3d));
|
267 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_effects3d_subtitle));
|
268 |
08f92d82
|
Leszek Koltunski
|
data.add(item);
|
269 |
76a81b6a
|
Leszek Koltunski
|
activityMapping.put(i++, Effects3DActivity.class);
|
270 |
df77c72c
|
Leszek Koltunski
|
}
|
271 |
|
|
|
272 |
862fcd79
|
Leszek Koltunski
|
{
|
273 |
a2cb31e9
|
Leszek Koltunski
|
final Map<String, Object> item = new HashMap<>();
|
274 |
862fcd79
|
Leszek Koltunski
|
item.put(ITEM_IMAGE, R.drawable.icon_example_monalisa);
|
275 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_plainmonalisa));
|
276 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_plainmonalisa_subtitle));
|
277 |
|
|
data.add(item);
|
278 |
|
|
activityMapping.put(i++, PlainMonaLisaActivity.class);
|
279 |
|
|
}
|
280 |
a2cb31e9
|
Leszek Koltunski
|
|
281 |
|
|
{
|
282 |
|
|
final Map<String, Object> item = new HashMap<>();
|
283 |
|
|
item.put(ITEM_IMAGE, R.drawable.icon_example_girl);
|
284 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_save));
|
285 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_save_subtitle));
|
286 |
|
|
data.add(item);
|
287 |
|
|
activityMapping.put(i++, SaveActivity.class);
|
288 |
|
|
}
|
289 |
|
|
|
290 |
175f355d
|
Leszek Koltunski
|
{
|
291 |
|
|
final Map<String, Object> item = new HashMap<>();
|
292 |
|
|
item.put(ITEM_IMAGE, R.drawable.icon_example_flag);
|
293 |
|
|
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_flag));
|
294 |
|
|
item.put(ITEM_SUBTITLE, getText(R.string.example_flag_subtitle));
|
295 |
|
|
data.add(item);
|
296 |
|
|
activityMapping.put(i++, FlagActivity.class);
|
297 |
|
|
}
|
298 |
|
|
|
299 |
427ab7bf
|
Leszek Koltunski
|
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});
|
300 |
|
|
setListAdapter(dataAdapter);
|
301 |
|
|
|
302 |
|
|
getListView().setOnItemClickListener(new OnItemClickListener()
|
303 |
|
|
{
|
304 |
|
|
@Override
|
305 |
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
306 |
|
|
{
|
307 |
|
|
final Class<? extends Activity> activityToLaunch = activityMapping.get(position);
|
308 |
|
|
|
309 |
|
|
if (activityToLaunch != null)
|
310 |
|
|
{
|
311 |
|
|
final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch);
|
312 |
|
|
startActivity(launchIntent);
|
313 |
|
|
}
|
314 |
|
|
}
|
315 |
|
|
});
|
316 |
|
|
}
|
317 |
|
|
}
|
318 |
|
|
|
319 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|