1 |
5068fa06
|
Leszek Koltunski
|
package org.distorted.examples.movingeffects;
|
2 |
427ab7bf
|
Leszek Koltunski
|
|
3 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.library.Distorted;
|
4 |
|
|
import org.distorted.examples.R;
|
5 |
427ab7bf
|
Leszek Koltunski
|
|
6 |
|
|
import android.app.Activity;
|
7 |
|
|
import android.opengl.GLSurfaceView;
|
8 |
|
|
import android.os.Bundle;
|
9 |
|
|
import android.view.View;
|
10 |
|
|
import android.widget.Button;
|
11 |
|
|
import android.widget.Toast;
|
12 |
|
|
|
13 |
|
|
///////////////////////////////////////////////////////////////////
|
14 |
|
|
|
15 |
|
|
public class MovingEffectsActivity extends Activity
|
16 |
|
|
{
|
17 |
|
|
private static final int COLOR_PRESSED = 0xff0000ff;
|
18 |
|
|
private static final int COLOR_UNPRESSED = 0x888888ff;
|
19 |
|
|
private static final String SHOWED_TOAST = "showed_toast";
|
20 |
|
|
|
21 |
|
|
Button mAbort, mMacro, mTrans, mSink, mBubble, mSwirl;
|
22 |
|
|
|
23 |
|
|
///////////////////////////////////////////////////////////////////
|
24 |
|
|
@Override
|
25 |
|
|
protected void onCreate(Bundle savedState)
|
26 |
|
|
{
|
27 |
|
|
super.onCreate(savedState);
|
28 |
|
|
|
29 |
|
|
setContentView(R.layout.movingeffectslayout);
|
30 |
|
|
|
31 |
|
|
mAbort = (Button)findViewById(R.id.movingeffectsAbort);
|
32 |
|
|
mMacro = (Button)findViewById(R.id.movingeffectsMacro);
|
33 |
|
|
mTrans = (Button)findViewById(R.id.movingeffectsTrans);
|
34 |
|
|
mSink = (Button)findViewById(R.id.movingeffectsSink);
|
35 |
|
|
mBubble= (Button)findViewById(R.id.movingeffectsBubble);
|
36 |
|
|
mSwirl= (Button)findViewById(R.id.movingeffectsSwirl);
|
37 |
|
|
|
38 |
|
|
mAbort.setBackgroundColor(COLOR_PRESSED);
|
39 |
|
|
mMacro.setBackgroundColor(COLOR_UNPRESSED);
|
40 |
|
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
41 |
|
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
42 |
|
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
43 |
|
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
44 |
|
|
|
45 |
|
|
if ( savedState== null || !savedState.getBoolean(SHOWED_TOAST, false))
|
46 |
|
|
{
|
47 |
|
|
Toast.makeText(this, R.string.example_movingeffects_toast , Toast.LENGTH_LONG).show();
|
48 |
|
|
}
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
///////////////////////////////////////////////////////////////////
|
52 |
|
|
@Override
|
53 |
|
|
protected void onResume()
|
54 |
|
|
{
|
55 |
|
|
super.onResume();
|
56 |
|
|
|
57 |
|
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
|
58 |
|
|
mView.onResume();
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
///////////////////////////////////////////////////////////////////
|
62 |
|
|
@Override
|
63 |
|
|
protected void onPause()
|
64 |
|
|
{
|
65 |
|
|
Abort(null);
|
66 |
|
|
|
67 |
|
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
|
68 |
|
|
mView.onPause();
|
69 |
|
|
|
70 |
|
|
super.onPause();
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
///////////////////////////////////////////////////////////////////
|
74 |
|
|
@Override
|
75 |
|
|
public void onStop()
|
76 |
|
|
{
|
77 |
|
|
super.onStop();
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
///////////////////////////////////////////////////////////////////
|
81 |
|
|
@Override
|
82 |
|
|
public void onDestroy()
|
83 |
|
|
{
|
84 |
|
|
Distorted.onDestroy();
|
85 |
|
|
super.onDestroy();
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89 |
|
|
|
90 |
|
|
@Override
|
91 |
|
|
protected void onSaveInstanceState (Bundle outState)
|
92 |
|
|
{
|
93 |
|
|
outState.putBoolean(SHOWED_TOAST, true);
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
///////////////////////////////////////////////////////////////////
|
97 |
|
|
|
98 |
|
|
public void Bubble(View v)
|
99 |
|
|
{
|
100 |
|
|
MovingEffectsSurfaceView.Bubble();
|
101 |
|
|
|
102 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
103 |
|
|
mMacro.setBackgroundColor(COLOR_UNPRESSED);
|
104 |
|
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
105 |
|
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
106 |
|
|
mBubble.setBackgroundColor(COLOR_PRESSED);
|
107 |
|
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
///////////////////////////////////////////////////////////////////
|
111 |
|
|
|
112 |
|
|
public void Sink(View v)
|
113 |
|
|
{
|
114 |
|
|
MovingEffectsSurfaceView.Sink();
|
115 |
|
|
|
116 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
117 |
|
|
mMacro.setBackgroundColor(COLOR_UNPRESSED);
|
118 |
|
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
119 |
|
|
mSink.setBackgroundColor(COLOR_PRESSED);
|
120 |
|
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
121 |
|
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
///////////////////////////////////////////////////////////////////
|
125 |
|
|
|
126 |
|
|
public void Transparency(View v)
|
127 |
|
|
{
|
128 |
|
|
MovingEffectsSurfaceView.Transparency();
|
129 |
|
|
|
130 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
131 |
|
|
mMacro.setBackgroundColor(COLOR_UNPRESSED);
|
132 |
|
|
mTrans.setBackgroundColor(COLOR_PRESSED);
|
133 |
|
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
134 |
|
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
135 |
|
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
///////////////////////////////////////////////////////////////////
|
139 |
|
|
|
140 |
|
|
public void Macroblock(View v)
|
141 |
|
|
{
|
142 |
|
|
MovingEffectsSurfaceView.Macroblock();
|
143 |
|
|
|
144 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
145 |
|
|
mMacro.setBackgroundColor(COLOR_PRESSED);
|
146 |
|
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
147 |
|
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
148 |
|
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
149 |
|
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
///////////////////////////////////////////////////////////////////
|
153 |
|
|
|
154 |
|
|
public void Swirl(View v)
|
155 |
|
|
{
|
156 |
|
|
MovingEffectsSurfaceView.Swirl();
|
157 |
|
|
|
158 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
159 |
|
|
mMacro.setBackgroundColor(COLOR_UNPRESSED);
|
160 |
|
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
161 |
|
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
162 |
|
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
163 |
|
|
mSwirl.setBackgroundColor(COLOR_PRESSED);
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
///////////////////////////////////////////////////////////////////
|
167 |
|
|
|
168 |
|
|
public void Abort(View v)
|
169 |
|
|
{
|
170 |
|
|
MovingEffectsSurfaceView.Abort();
|
171 |
|
|
|
172 |
|
|
mAbort.setBackgroundColor(COLOR_PRESSED);
|
173 |
|
|
mMacro.setBackgroundColor(COLOR_UNPRESSED);
|
174 |
|
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
175 |
|
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
176 |
|
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
177 |
|
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
///////////////////////////////////////////////////////////////////
|
181 |
|
|
// end of file
|
182 |
|
|
}
|