Project

General

Profile

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

examples / src / main / java / org / distorted / examples / save / SaveActivity.java @ e4237c21

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

    
22
import org.distorted.library.Distorted;
23
import org.distorted.examples.R;
24

    
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.SeekBar;
31

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

    
34
public class SaveActivity extends Activity implements SeekBar.OnSeekBarChangeListener
35
  {
36
  private Button mSave;
37
  private SeekBar barSize;
38

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40
    
41
  @Override
42
  protected void onCreate(Bundle icicle) 
43
    {
44
    super.onCreate(icicle);
45
     
46
    setContentView(R.layout.savelayout);
47
           
48
    mSave = (Button)findViewById(R.id.saveButton);
49

    
50
    barSize  = (SeekBar)findViewById(R.id.saveSeekBar);
51
    barSize.setOnSeekBarChangeListener(this);
52
    barSize.setProgress(50);
53
    }
54

    
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56
    
57
  @Override
58
  protected void onPause() 
59
    {
60
    SaveRenderer.stopThread();
61

    
62
    GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.saveSurfaceView);
63
    mView.onPause();
64
      
65
    super.onPause();
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69
    
70
  @Override
71
  protected void onResume() 
72
    {
73
    super.onResume();
74
      
75
    GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.saveSurfaceView);
76
    mView.onResume();
77

    
78
    SaveRenderer.startThread(this);
79
    }
80
 
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
    
83
  @Override
84
  protected void onDestroy() 
85
    {
86
    Distorted.onDestroy();  
87
    super.onDestroy();
88
    }
89
   
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  public void Save(View v)
93
    {
94
    SaveRenderer.Save();
95
    }
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

    
99
  public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
100
    {
101
    float s = (progress>50 ? ((progress-50)/16.0f + 1.0f):(0.015f*progress + 0.25f));
102
    SaveRenderer.setSize(s);
103
    }
104

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106

    
107
  public void onStartTrackingTouch(SeekBar bar) { }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

    
111
  public void onStopTrackingTouch(SeekBar bar)  { }
112

    
113
  }
(1-1/4)