Project

General

Profile

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

examples / src / main / java / org / distorted / examples / blur / BlurActivity.java @ 77e66c58

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
package org.distorted.examples.blur;
21

    
22
import android.app.Activity;
23
import android.opengl.GLSurfaceView;
24
import android.os.Bundle;
25
import android.widget.SeekBar;
26
import android.widget.SeekBar.OnSeekBarChangeListener;
27
import android.widget.TextView;
28

    
29
import org.distorted.examples.R;
30
import org.distorted.library.main.DistortedLibrary;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
public class BlurActivity extends Activity  implements OnSeekBarChangeListener
35
{
36
    private TextView textBlur, textHalo, textMove;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
    
40
    @Override
41
    protected void onCreate(Bundle icicle) 
42
      {
43
      super.onCreate(icicle);
44
      DistortedLibrary.onCreate();
45

    
46
      setContentView(R.layout.blurlayout);
47

    
48
      textBlur = findViewById(R.id.blurText);
49
      textHalo = findViewById(R.id.haloText);
50
      textMove = findViewById(R.id.moveText);
51

    
52
      SeekBar barB = findViewById(R.id.blurSeek);
53
      barB.setOnSeekBarChangeListener(this);
54
      barB.setProgress(50);
55

    
56
      SeekBar barH = findViewById(R.id.haloSeek);
57
      barH.setOnSeekBarChangeListener(this);
58
      barH.setProgress(50);
59

    
60
      SeekBar barM = findViewById(R.id.moveSeek);
61
      barM.setOnSeekBarChangeListener(this);
62
      barM.setProgress(50);
63
      }
64

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66
    
67
    @Override
68
    protected void onPause() 
69
      {
70
      super.onPause();
71
      GLSurfaceView view = findViewById(R.id.blurSurfaceView);
72
      view.onPause();
73
      DistortedLibrary.onPause();
74
      }
75

    
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77
    
78
    @Override
79
    protected void onResume() 
80
      {
81
      super.onResume();
82
      GLSurfaceView view = findViewById(R.id.blurSurfaceView);
83
      view.onResume();
84
      }
85
 
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87
    
88
    @Override
89
    protected void onDestroy() 
90
      {
91
      DistortedLibrary.onDestroy();
92
      super.onDestroy();
93
      }
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96
    
97
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
98
      {
99
      BlurSurfaceView v = findViewById(R.id.blurSurfaceView);
100
      BlurRenderer r = v.getRenderer();
101
      int id = bar.getId();
102

    
103
      if( id == R.id.blurSeek )
104
        {
105
        int l = r.setBlur(progress);
106
        textBlur.setText(getString(R.string.blur_placeholder,l));
107
        }
108
      if( id == R.id.haloSeek )
109
        {
110
        int l = r.setHalo(progress);
111
        textHalo.setText(getString(R.string.halo_placeholder,l));
112
        }
113
      if( id == R.id.moveSeek )
114
        {
115
        int l = r.setMove(progress);
116
        textMove.setText(getString(R.string.move_placeholder,l));
117
        }
118
      }
119

    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

    
122
    public void onStartTrackingTouch(SeekBar bar) { }
123

    
124
///////////////////////////////////////////////////////////////////////////////////////////////////
125

    
126
    public void onStopTrackingTouch(SeekBar bar)  { }
127
     
128
}
(1-1/3)