| 1 |
bc0a685b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
| 3 |
|
|
// //
|
| 4 |
71c8884f
|
Leszek Koltunski
|
// This file is part of Distorted. //
|
| 5 |
bc0a685b
|
Leszek Koltunski
|
// //
|
| 6 |
71c8884f
|
Leszek Koltunski
|
// Distorted is free software: you can redistribute it and/or modify //
|
| 7 |
bc0a685b
|
Leszek Koltunski
|
// 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 |
71c8884f
|
Leszek Koltunski
|
// Distorted is distributed in the hope that it will be useful, //
|
| 12 |
bc0a685b
|
Leszek Koltunski
|
// 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 |
71c8884f
|
Leszek Koltunski
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
| 18 |
bc0a685b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 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 |
887e1853
|
Leszek Koltunski
|
import org.distorted.examples.deferredjob.DeferredJobActivity;
|
| 38 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.monalisa.MonaLisaActivity;
|
| 39 |
|
|
import org.distorted.examples.sink.SinkActivity;
|
| 40 |
10d53839
|
Leszek Koltunski
|
import org.distorted.examples.projection.ProjectionActivity;
|
| 41 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.deform.DeformActivity;
|
| 42 |
|
|
import org.distorted.examples.listener.ListenerActivity;
|
| 43 |
f988589e
|
Leszek Koltunski
|
import org.distorted.examples.dynamic.DynamicActivity;
|
| 44 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.girl.GirlActivity;
|
| 45 |
f26ab2fd
|
Leszek Koltunski
|
import org.distorted.examples.catanddog.CatAndDogActivity;
|
| 46 |
5068fa06
|
Leszek Koltunski
|
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 |
758303a3
|
Leszek Koltunski
|
import org.distorted.examples.effectqueue.EffectQueueActivity;
|
| 51 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.check.CheckActivity;
|
| 52 |
|
|
import org.distorted.examples.bean.BeanActivity;
|
| 53 |
5ceea148
|
Leszek Koltunski
|
import org.distorted.examples.objecttree.ObjectTreeActivity;
|
| 54 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.starwars.StarWarsActivity;
|
| 55 |
64558e4e
|
Leszek Koltunski
|
import org.distorted.examples.inflate.InflateActivity;
|
| 56 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.quaternion.QuaternionActivity;
|
| 57 |
46b26cdc
|
Leszek Koltunski
|
import org.distorted.examples.generic.GenericActivity;
|
| 58 |
0de83d97
|
Leszek Koltunski
|
import org.distorted.examples.surfaceview.SurfaceViewActivity;
|
| 59 |
a2cb31e9
|
Leszek Koltunski
|
import org.distorted.examples.save.SaveActivity;
|
| 60 |
175f355d
|
Leszek Koltunski
|
import org.distorted.examples.flag.FlagActivity;
|
| 61 |
14122c52
|
Leszek Koltunski
|
import org.distorted.examples.wind.WindActivity;
|
| 62 |
4f39a7d1
|
Leszek Koltunski
|
import org.distorted.examples.aroundtheworld.AroundTheWorldActivity;
|
| 63 |
03a2fd30
|
Leszek Koltunski
|
import org.distorted.examples.mirror.MirrorActivity;
|
| 64 |
43bda3db
|
Leszek Koltunski
|
import org.distorted.examples.blur.BlurActivity;
|
| 65 |
58059374
|
Leszek Koltunski
|
import org.distorted.examples.multiblur.MultiblurActivity;
|
| 66 |
80f37d1b
|
Leszek Koltunski
|
import org.distorted.examples.triblur.TriblurActivity;
|
| 67 |
664a0e45
|
Leszek Koltunski
|
import org.distorted.examples.transparency.TransparencyActivity;
|
| 68 |
efc280af
|
Leszek Koltunski
|
import org.distorted.examples.postprocesstree.PostprocessTreeActivity;
|
| 69 |
32d08f39
|
Leszek Koltunski
|
import org.distorted.examples.stencil.StencilActivity;
|
| 70 |
cb9d104d
|
Leszek Koltunski
|
import org.distorted.examples.glow.GlowActivity;
|
| 71 |
11298b49
|
Leszek Koltunski
|
import org.distorted.examples.movingglow.MovingGlowActivity;
|
| 72 |
64558e4e
|
Leszek Koltunski
|
import org.distorted.examples.earth.EarthActivity;
|
| 73 |
5b4a2d76
|
Leszek Koltunski
|
import org.distorted.examples.rubik.RubikActivity;
|
| 74 |
508ee98f
|
Leszek Koltunski
|
import org.distorted.examples.meshjoin.MeshJoinActivity;
|
| 75 |
59835a0a
|
Leszek Koltunski
|
import org.distorted.examples.predeform.PredeformActivity;
|
| 76 |
427ab7bf
|
Leszek Koltunski
|
|
| 77 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 78 |
|
|
|
| 79 |
|
|
public class TableOfContents extends ListActivity
|
| 80 |
|
|
{
|
| 81 |
bca41c80
|
Leszek Koltunski
|
private static final String ITEM_IMAGE = "item_image";
|
| 82 |
|
|
private static final String ITEM_TITLE = "item_title";
|
| 83 |
427ab7bf
|
Leszek Koltunski
|
private static final String ITEM_SUBTITLE = "item_subtitle";
|
| 84 |
|
|
|
| 85 |
bca41c80
|
Leszek Koltunski
|
private enum Application
|
| 86 |
|
|
{
|
| 87 |
|
|
MONALISA (R.drawable.icon_example_monalisa , R.string.example_monalisa , R.string.example_monalisa_subtitle , MonaLisaActivity.class),
|
| 88 |
|
|
SINK (R.drawable.icon_example_sink , R.string.example_sink , R.string.example_sink_subtitle , SinkActivity.class),
|
| 89 |
|
|
BEAN (R.drawable.icon_example_bean , R.string.example_bean , R.string.example_bean_subtitle , BeanActivity.class),
|
| 90 |
|
|
PROJECTION (R.drawable.icon_example_projection , R.string.example_projection , R.string.example_projection_subtitle , ProjectionActivity.class),
|
| 91 |
|
|
DEFORM (R.drawable.icon_example_deform , R.string.example_deform , R.string.example_deform_subtitle , DeformActivity.class),
|
| 92 |
|
|
LISTENER (R.drawable.icon_example_listener , R.string.example_listener , R.string.example_listener_subtitle , ListenerActivity.class),
|
| 93 |
|
|
DYNAMIC (R.drawable.icon_example_dynamic , R.string.example_dynamic , R.string.example_dynamic_subtitle , DynamicActivity.class),
|
| 94 |
|
|
GIRL (R.drawable.icon_example_girl , R.string.example_girl , R.string.example_girl_subtitle , GirlActivity.class),
|
| 95 |
|
|
CATANDDOG (R.drawable.icon_example_catanddog , R.string.example_catanddog , R.string.example_catanddog_subtitle , CatAndDogActivity.class),
|
| 96 |
|
|
MOVINGEFFECTS (R.drawable.icon_example_movingeffects , R.string.example_movingeffects , R.string.example_movingeffects_subtitle , MovingEffectsActivity.class),
|
| 97 |
|
|
DIFFERENTEFFECTS (R.drawable.icon_example_differenteffects, R.string.example_differenteffects, R.string.example_differenteffects_subtitle, DifferentEffectsActivity.class),
|
| 98 |
|
|
DIFFERENTBITMAPS (R.drawable.icon_example_differentbitmaps, R.string.example_differentbitmaps, R.string.example_differentbitmaps_subtitle, DifferentBitmapsActivity.class),
|
| 99 |
|
|
EFFECTQUEUE (R.drawable.icon_example_effectqueue , R.string.example_effectqueue , R.string.example_effectqueue_subtitle , EffectQueueActivity.class),
|
| 100 |
|
|
CHECK (R.drawable.icon_example_check , R.string.example_check , R.string.example_check_subtitle , CheckActivity.class),
|
| 101 |
|
|
OBJECTTREE (R.drawable.icon_example_objecttree , R.string.example_objecttree , R.string.example_objecttree_subtitle , ObjectTreeActivity.class),
|
| 102 |
|
|
STARWARS (R.drawable.icon_example_starwars , R.string.example_starwars , R.string.example_starwars_subtitle , StarWarsActivity.class),
|
| 103 |
|
|
OLIMPIC (R.drawable.icon_example_olimpic , R.string.example_olimpic , R.string.example_olimpic_subtitle , OlimpicActivity.class),
|
| 104 |
|
|
QUATERNION (R.drawable.icon_example_quaternion , R.string.example_quaternion , R.string.example_quaternion_subtitle , QuaternionActivity.class),
|
| 105 |
|
|
INFLATE (R.drawable.icon_example_inflate , R.string.example_inflate , R.string.example_inflate_subtitle , InflateActivity.class),
|
| 106 |
|
|
GENERIC (R.drawable.icon_example_generic , R.string.example_generic , R.string.example_generic_subtitle , GenericActivity.class),
|
| 107 |
386fd702
|
Leszek Koltunski
|
SURFACEVIEW (R.drawable.icon_example_monalisa , R.string.example_surfaceview , R.string.example_surfaceview_subtitle , SurfaceViewActivity.class),
|
| 108 |
bca41c80
|
Leszek Koltunski
|
SAVE (R.drawable.icon_example_save , R.string.example_save , R.string.example_save_subtitle , SaveActivity.class),
|
| 109 |
|
|
FLAG (R.drawable.icon_example_flag , R.string.example_flag , R.string.example_flag_subtitle , FlagActivity.class),
|
| 110 |
|
|
WIND (R.drawable.icon_example_wind , R.string.example_wind , R.string.example_wind_subtitle , WindActivity.class),
|
| 111 |
|
|
AROUNDTHEWORLD (R.drawable.icon_example_aroundtheworld , R.string.example_aroundtheworld , R.string.example_aroundtheworld_subtitle , AroundTheWorldActivity.class),
|
| 112 |
|
|
MIRROR (R.drawable.icon_example_mirror , R.string.example_mirror , R.string.example_mirror_subtitle , MirrorActivity.class),
|
| 113 |
|
|
STENCIL (R.drawable.icon_example_stencil , R.string.example_stencil , R.string.example_stencil_subtitle , StencilActivity.class),
|
| 114 |
|
|
BLUR (R.drawable.icon_example_blur , R.string.example_blur , R.string.example_blur_subtitle , BlurActivity.class),
|
| 115 |
|
|
MULTIBLUR (R.drawable.icon_example_multiblur , R.string.example_multiblur , R.string.example_multiblur_subtitle , MultiblurActivity.class),
|
| 116 |
|
|
TRIBLUR (R.drawable.icon_example_triblur , R.string.example_triblur , R.string.example_triblur_subtitle , TriblurActivity.class),
|
| 117 |
|
|
TRANSPARENCY (R.drawable.icon_example_transparency , R.string.example_transparency , R.string.example_transparency_subtitle , TransparencyActivity.class),
|
| 118 |
|
|
POSTPROCESSTREE (R.drawable.icon_example_postprocesstree , R.string.example_postprocesstree , R.string.example_postprocesstree_subtitle , PostprocessTreeActivity.class),
|
| 119 |
|
|
GLOW (R.drawable.icon_example_glow , R.string.example_glow , R.string.example_glow_subtitle , GlowActivity.class),
|
| 120 |
|
|
MOVINGGLOW (R.drawable.icon_example_movingglow , R.string.example_moving_glow , R.string.example_moving_glow_subtitle , MovingGlowActivity.class),
|
| 121 |
|
|
EARTH (R.drawable.icon_example_earth , R.string.example_earth , R.string.example_earth_subtitle , EarthActivity.class),
|
| 122 |
508ee98f
|
Leszek Koltunski
|
RUBIK (R.drawable.icon_example_rubik , R.string.example_rubik , R.string.example_rubik_subtitle , RubikActivity.class),
|
| 123 |
a71ef7f1
|
Leszek Koltunski
|
MESHJOIN (R.drawable.icon_example_meshjoin , R.string.example_meshjoin , R.string.example_meshjoin_subtitle , MeshJoinActivity.class),
|
| 124 |
3c219720
|
Leszek Koltunski
|
PREDEFORM (R.drawable.icon_example_predeform , R.string.example_predeform , R.string.example_predeform_subtitle , PredeformActivity.class),
|
| 125 |
887e1853
|
Leszek Koltunski
|
DEFERREDJOB (R.drawable.icon_example_wip , R.string.example_deferredjob , R.string.example_deferredjob_subtitle , DeferredJobActivity.class),
|
| 126 |
bca41c80
|
Leszek Koltunski
|
;
|
| 127 |
|
|
|
| 128 |
|
|
final int icon, title, subtitle;
|
| 129 |
|
|
final Class<? extends Activity> activity;
|
| 130 |
|
|
|
| 131 |
|
|
Application(int i, int t, int s, Class<? extends Activity> a)
|
| 132 |
|
|
{
|
| 133 |
|
|
icon = i;
|
| 134 |
|
|
title = t;
|
| 135 |
|
|
subtitle = s;
|
| 136 |
|
|
activity = a;
|
| 137 |
|
|
}
|
| 138 |
|
|
}
|
| 139 |
|
|
|
| 140 |
427ab7bf
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 141 |
|
|
|
| 142 |
|
|
@Override
|
| 143 |
|
|
public void onCreate(Bundle savedInstanceState)
|
| 144 |
f209a803
|
Leszek Koltunski
|
{
|
| 145 |
|
|
super.onCreate(savedInstanceState);
|
| 146 |
|
|
setContentView(R.layout.table_of_contents);
|
| 147 |
427ab7bf
|
Leszek Koltunski
|
|
| 148 |
f209a803
|
Leszek Koltunski
|
final List<Map<String, Object>> data = new ArrayList<>();
|
| 149 |
|
|
final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>();
|
| 150 |
6ce08079
|
Leszek Koltunski
|
|
| 151 |
f209a803
|
Leszek Koltunski
|
int index=0;
|
| 152 |
efc280af
|
Leszek Koltunski
|
|
| 153 |
f209a803
|
Leszek Koltunski
|
for( Application app : Application.values() )
|
| 154 |
|
|
{
|
| 155 |
|
|
final Map<String, Object> item = new HashMap<>();
|
| 156 |
|
|
item.put(ITEM_IMAGE, app.icon);
|
| 157 |
|
|
item.put(ITEM_TITLE, (index+1)+". "+getText(app.title));
|
| 158 |
|
|
item.put(ITEM_SUBTITLE, getText(app.subtitle));
|
| 159 |
|
|
data.add(item);
|
| 160 |
|
|
activityMapping.put(index++, app.activity);
|
| 161 |
|
|
}
|
| 162 |
bca41c80
|
Leszek Koltunski
|
|
| 163 |
f209a803
|
Leszek Koltunski
|
final SimpleAdapter dataAdapter = new SimpleAdapter( this,
|
| 164 |
|
|
data,
|
| 165 |
|
|
R.layout.toc_item,
|
| 166 |
|
|
new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE},
|
| 167 |
|
|
new int[] {R.id.Image, R.id.Title, R.id.SubTitle} );
|
| 168 |
|
|
setListAdapter(dataAdapter);
|
| 169 |
427ab7bf
|
Leszek Koltunski
|
|
| 170 |
f209a803
|
Leszek Koltunski
|
getListView().setOnItemClickListener(new OnItemClickListener()
|
| 171 |
427ab7bf
|
Leszek Koltunski
|
{
|
| 172 |
f209a803
|
Leszek Koltunski
|
@Override
|
| 173 |
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
|
| 174 |
427ab7bf
|
Leszek Koltunski
|
{
|
| 175 |
f209a803
|
Leszek Koltunski
|
final Class<? extends Activity> activityToLaunch = activityMapping.get(position);
|
| 176 |
|
|
|
| 177 |
|
|
if (activityToLaunch != null)
|
| 178 |
|
|
{
|
| 179 |
|
|
final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch);
|
| 180 |
|
|
startActivity(launchIntent);
|
| 181 |
|
|
}
|
| 182 |
|
|
}
|
| 183 |
|
|
});
|
| 184 |
|
|
}
|
| 185 |
427ab7bf
|
Leszek Koltunski
|
}
|