Project

General

Profile

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

examples / src / main / java / org / distorted / examples / movingeffects / MovingEffectsActivity.java @ f6d884d5

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