Project

General

Profile

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

examples / src / main / java / org / distorted / examples / objecttree / ObjectTreeActivity.java @ c0f27889

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

    
22
import org.distorted.examples.R;
23
import org.distorted.library.main.DistortedLibrary;
24

    
25
import android.app.Activity;
26
import android.os.Bundle;
27
import android.view.View;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
public class ObjectTreeActivity extends Activity
32
{
33
    private boolean mDepth;
34

    
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36
    
37
    @Override
38
    protected void onCreate(Bundle savedState)
39
      {
40
      super.onCreate(savedState);
41
      setContentView(R.layout.objecttreelayout);
42

    
43
      if( savedState==null )
44
        {
45
        mDepth = true;
46
        }
47
      }
48

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

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

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

    
81
    public void DepthYes(View v)
82
      {
83
      ObjectTreeSurfaceView view = findViewById(R.id.objecttreeSurfaceView);
84
      ObjectTreeRenderer renderer = view.getRenderer();
85

    
86
      renderer.setDepth(true);
87
      mDepth = true;
88
      }
89

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

    
92
    public void DepthNo(View v)
93
      {
94
      ObjectTreeSurfaceView view = findViewById(R.id.objecttreeSurfaceView);
95
      ObjectTreeRenderer renderer = view.getRenderer();
96

    
97
      renderer.setDepth(false);
98
      mDepth = false;
99
      }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
    @Override
104
    public void onSaveInstanceState(Bundle savedInstanceState)
105
      {
106
      super.onSaveInstanceState(savedInstanceState);
107
      savedInstanceState.putBoolean("depth", mDepth);
108
      }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
    @Override
113
    public void onRestoreInstanceState(Bundle savedInstanceState)
114
      {
115
      super.onRestoreInstanceState(savedInstanceState);
116

    
117
      mDepth = savedInstanceState.getBoolean("depth");
118

    
119
      if(mDepth) DepthYes(null);
120
      else       DepthNo(null);
121
      }
122

    
123
}
(1-1/3)