Project

General

Profile

« Previous | Next » 

Revision baeda47e

Added by Leszek Koltunski over 7 years ago

Improve Deform.

View differences:

src/main/java/org/distorted/examples/deform/DeformActivity.java
37 37
public class DeformActivity extends Activity implements OnSeekBarChangeListener
38 38
{
39 39
    private TextView textR;
40
    private EffectNames mCurrEffect;
40 41

  
41 42
///////////////////////////////////////////////////////////////////////////////////////////////////
42 43
    
43 44
    @Override
44
    protected void onCreate(Bundle icicle) 
45
    protected void onCreate(Bundle savedState)
45 46
      {
46
      super.onCreate(icicle);
47
      super.onCreate(savedState);
47 48
      setContentView(R.layout.deformlayout);
48 49

  
49
      SeekBar barR = (SeekBar)findViewById(R.id.deformSeekRadius);
50
      barR.setOnSeekBarChangeListener(this); 
51
        
52 50
      textR = (TextView)findViewById(R.id.deformTextRadius);
53
     
54
      barR.setProgress(50);
55
      
56
      textR.setText(getString(R.string.radius_placeholder,"50"));
57

  
58
      RadioButton effect = (RadioButton)findViewById(R.id.deformDistortButton);
59
      effect.setChecked(true);
60 51

  
61
      DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
52
      SeekBar barR = (SeekBar)findViewById(R.id.deformSeekRadius);
53
      barR.setOnSeekBarChangeListener(this);
62 54

  
63
      view.getRenderer().setMode(EffectNames.DISTORT);
55
      if( savedState==null )
56
        {
57
        barR.setProgress(50);
58
        RadioButton effect = (RadioButton)findViewById(R.id.deformDistortButton);
59
        effect.setChecked(true);
60
        Distort(null);
61
        }
64 62
      }
65 63

  
66 64
///////////////////////////////////////////////////////////////////////////////////////////////////
......
101 99
      {
102 100
      DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
103 101
      view.getRenderer().setMode(EffectNames.DISTORT);
102
      mCurrEffect = EffectNames.DISTORT;
104 103
      }     
105 104
    
106 105
///////////////////////////////////////////////////////////////////////////////////////////////////
......
109 108
      {
110 109
      DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
111 110
      view.getRenderer().setMode(EffectNames.DEFORM);
111
      mCurrEffect = EffectNames.DEFORM;
112 112
      }       
113 113

  
114 114
///////////////////////////////////////////////////////////////////////////////////////////////////
......
117 117
      {
118 118
      DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
119 119
      view.getRenderer().setMode(EffectNames.SHEAR);
120
      mCurrEffect = EffectNames.SHEAR;
120 121
      }       
121
    
122

  
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

  
125
    @Override
126
    public void onSaveInstanceState(Bundle savedInstanceState)
127
      {
128
      super.onSaveInstanceState(savedInstanceState);
129
      savedInstanceState.putInt("effect", mCurrEffect.ordinal() );
130
      }
131

  
132
///////////////////////////////////////////////////////////////////////////////////////////////////
133

  
134
    @Override
135
    public void onRestoreInstanceState(Bundle savedInstanceState)
136
      {
137
      super.onRestoreInstanceState(savedInstanceState);
138

  
139
      int effect = savedInstanceState.getInt("effect");
140

  
141
      if( effect == EffectNames.DISTORT.ordinal() ) Distort(null);
142
      if( effect == EffectNames.DEFORM.ordinal()  ) Deform(null);
143
      if( effect == EffectNames.SHEAR.ordinal()   ) Shear(null);
144
      }
145

  
122 146
///////////////////////////////////////////////////////////////////////////////////////////////////
123 147
    
124 148
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 

Also available in: Unified diff