Project

General

Profile

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

examples / src / main / java / org / distorted / examples / flatblur / FlatBlurActivity.java @ 0e65f4da

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.flatblur;
21

    
22
import android.app.Activity;
23
import android.opengl.GLSurfaceView;
24
import android.os.Bundle;
25
import android.view.View;
26
import android.widget.CheckBox;
27
import android.widget.SeekBar;
28

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

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

    
34
public class FlatBlurActivity extends Activity implements SeekBar.OnSeekBarChangeListener
35
{
36
    @Override
37
    protected void onCreate(Bundle savedState) 
38
      {
39
      super.onCreate(savedState);
40
      DistortedLibrary.onCreate();
41
      setContentView(R.layout.flatblurlayout);
42

    
43
      SeekBar barSize  = findViewById(R.id.flatblurBlurStrength);
44
      barSize.setOnSeekBarChangeListener(this);
45
      barSize.setProgress(0);
46
      }
47

    
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49
    
50
    @Override
51
    protected void onPause() 
52
      {
53
      super.onPause();
54
      GLSurfaceView view = findViewById(R.id.flatblurSurfaceView);
55
      view.onPause();
56
      DistortedLibrary.onPause();
57
      }
58

    
59
///////////////////////////////////////////////////////////////////////////////////////////////////
60
    
61
    @Override
62
    protected void onResume() 
63
      {
64
      super.onResume();
65
      GLSurfaceView view = findViewById(R.id.flatblurSurfaceView);
66
      view.onResume();
67
      }
68
    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70
    
71
    @Override
72
    protected void onDestroy() 
73
      {
74
      DistortedLibrary.onDestroy();
75
      super.onDestroy();
76
      }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

    
80
    public void enableBlur(View view)
81
      {
82
      CheckBox box = (CheckBox)view;
83
      boolean checked = box.isChecked();
84

    
85
      FlatBlurSurfaceView v = findViewById(R.id.flatblurSurfaceView);
86
      FlatBlurRenderer renderer = v.getRenderer();
87
      renderer.enableBlur(!checked);
88
      }
89

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
93
    {
94
    FlatBlurSurfaceView v = findViewById(R.id.flatblurSurfaceView);
95
    FlatBlurRenderer renderer = v.getRenderer();
96
    renderer.setBlurStrength(progress);
97
    }
98

    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100

    
101
  public void onStartTrackingTouch(SeekBar bar) { }
102

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  public void onStopTrackingTouch(SeekBar bar)  { }
106
}
(1-1/3)