Project

General

Profile

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

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

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.movingeffects;
21 427ab7bf Leszek Koltunski
22 e3900503 Leszek Koltunski
import org.distorted.library.main.DistortedLibrary;
23 5068fa06 Leszek Koltunski
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 a4d59c0b Leszek Koltunski
      mAbort = findViewById(R.id.movingeffectsAbort);
51
      mChroma= findViewById(R.id.movingeffectsChroma);
52
      mTrans = findViewById(R.id.movingeffectsTrans);
53
      mSink  = findViewById(R.id.movingeffectsSink);
54
      mBubble= findViewById(R.id.movingeffectsBubble);
55
      mSwirl = findViewById(R.id.movingeffectsSwirl);
56 427ab7bf Leszek Koltunski
      
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 a4d59c0b Leszek Koltunski
72 427ab7bf Leszek Koltunski
    @Override
73 c0f27889 Leszek Koltunski
    protected void onPause()
74 427ab7bf Leszek Koltunski
      {
75 c0f27889 Leszek Koltunski
      Abort(null);
76
77
      super.onPause();
78 a4d59c0b Leszek Koltunski
      GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
79 c0f27889 Leszek Koltunski
      view.onPause();
80
      DistortedLibrary.onPause();
81 427ab7bf Leszek Koltunski
      }
82
83
///////////////////////////////////////////////////////////////////
84 a4d59c0b Leszek Koltunski
85 427ab7bf Leszek Koltunski
    @Override
86 c0f27889 Leszek Koltunski
    protected void onResume() 
87 427ab7bf Leszek Koltunski
      {
88 c0f27889 Leszek Koltunski
      super.onResume();
89 a4d59c0b Leszek Koltunski
      GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
90 c0f27889 Leszek Koltunski
      view.onResume();
91 427ab7bf Leszek Koltunski
      }
92 c0f27889 Leszek Koltunski
93 427ab7bf Leszek Koltunski
///////////////////////////////////////////////////////////////////
94 a4d59c0b Leszek Koltunski
95 427ab7bf Leszek Koltunski
    @Override
96
    public void onStop()
97
      {
98
      super.onStop();
99
      }
100
101
///////////////////////////////////////////////////////////////////
102
    @Override
103
    public void onDestroy()
104
      {
105 e3900503 Leszek Koltunski
      DistortedLibrary.onDestroy();
106 427ab7bf Leszek Koltunski
      super.onDestroy();
107
      }     
108
   
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110
    
111
    @Override
112
    protected void onSaveInstanceState (Bundle outState)
113
      {
114
      outState.putBoolean(SHOWED_TOAST, true);
115
      }
116
     
117
///////////////////////////////////////////////////////////////////
118
    
119
    public void Bubble(View v)
120
      {
121 a4d59c0b Leszek Koltunski
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
122 4562f295 Leszek Koltunski
      view.Bubble();
123 427ab7bf Leszek Koltunski
      
124
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
125 4348b52e Leszek Koltunski
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
126 427ab7bf Leszek Koltunski
      mTrans.setBackgroundColor(COLOR_UNPRESSED);
127
      mSink.setBackgroundColor(COLOR_UNPRESSED);
128
      mBubble.setBackgroundColor(COLOR_PRESSED);
129
      mSwirl.setBackgroundColor(COLOR_UNPRESSED);
130
      }     
131
    
132
///////////////////////////////////////////////////////////////////
133
134
    public void Sink(View v)
135
      {
136 a4d59c0b Leszek Koltunski
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
137 4562f295 Leszek Koltunski
      view.Sink();
138 427ab7bf Leszek Koltunski
      
139
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
140 4348b52e Leszek Koltunski
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
141 427ab7bf Leszek Koltunski
      mTrans.setBackgroundColor(COLOR_UNPRESSED);
142
      mSink.setBackgroundColor(COLOR_PRESSED);
143
      mBubble.setBackgroundColor(COLOR_UNPRESSED);
144
      mSwirl.setBackgroundColor(COLOR_UNPRESSED);
145
      }       
146
147
///////////////////////////////////////////////////////////////////
148
    
149
    public void Transparency(View v)
150
      {
151 a4d59c0b Leszek Koltunski
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
152 4562f295 Leszek Koltunski
      view.Transparency();
153 427ab7bf Leszek Koltunski
      
154
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
155 4348b52e Leszek Koltunski
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
156 427ab7bf Leszek Koltunski
      mTrans.setBackgroundColor(COLOR_PRESSED);
157
      mSink.setBackgroundColor(COLOR_UNPRESSED);
158
      mBubble.setBackgroundColor(COLOR_UNPRESSED);
159
      mSwirl.setBackgroundColor(COLOR_UNPRESSED);
160
      }     
161
    
162
///////////////////////////////////////////////////////////////////
163
164 4348b52e Leszek Koltunski
    public void Chroma(View v)
165 427ab7bf Leszek Koltunski
      {
166 a4d59c0b Leszek Koltunski
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
167 4562f295 Leszek Koltunski
      view.Chroma();
168 427ab7bf Leszek Koltunski
      
169
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
170 4348b52e Leszek Koltunski
      mChroma.setBackgroundColor(COLOR_PRESSED);
171 427ab7bf Leszek Koltunski
      mTrans.setBackgroundColor(COLOR_UNPRESSED);
172
      mSink.setBackgroundColor(COLOR_UNPRESSED);
173
      mBubble.setBackgroundColor(COLOR_UNPRESSED);
174
      mSwirl.setBackgroundColor(COLOR_UNPRESSED);
175
      }       
176
177
///////////////////////////////////////////////////////////////////
178
179
    public void Swirl(View v)
180
      {
181 a4d59c0b Leszek Koltunski
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
182 4562f295 Leszek Koltunski
      view.Swirl();
183 427ab7bf Leszek Koltunski
      
184
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
185 4348b52e Leszek Koltunski
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
186 427ab7bf Leszek Koltunski
      mTrans.setBackgroundColor(COLOR_UNPRESSED);
187
      mSink.setBackgroundColor(COLOR_UNPRESSED);
188
      mBubble.setBackgroundColor(COLOR_UNPRESSED);
189
      mSwirl.setBackgroundColor(COLOR_PRESSED);
190
      }       
191
    
192
///////////////////////////////////////////////////////////////////
193
194
    public void Abort(View v)
195
      {
196 a4d59c0b Leszek Koltunski
      MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
197 4562f295 Leszek Koltunski
      view.Abort();
198 427ab7bf Leszek Koltunski
      
199
      mAbort.setBackgroundColor(COLOR_PRESSED);
200 4348b52e Leszek Koltunski
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
201 427ab7bf Leszek Koltunski
      mTrans.setBackgroundColor(COLOR_UNPRESSED);
202
      mSink.setBackgroundColor(COLOR_UNPRESSED);
203
      mBubble.setBackgroundColor(COLOR_UNPRESSED);
204
      mSwirl.setBackgroundColor(COLOR_UNPRESSED);
205
      }
206
}