Project

General

Profile

« Previous | Next » 

Revision 280dc794

Added by Leszek Koltunski almost 3 years ago

Improve the behaviour of the Config and Tutorial activities when in the 'PopUpMode'. Also, remember the current object in the COnfig activity so that when we put it to the background and resume - the object stays.

View differences:

src/main/java/org/distorted/config/ConfigActivity.java
35 35
import org.distorted.dmesh.ObjectMesh;
36 36
import org.distorted.jsons.ObjectJson;
37 37
import org.distorted.library.main.DistortedLibrary;
38
import org.distorted.library.type.Static4D;
39 38
import org.distorted.main.R;
40 39
import org.distorted.objectlib.main.ObjectControl;
41
import org.distorted.objectlib.main.ShapeDodecahedron;
42
import org.distorted.objectlib.main.ShapeHexahedron;
43
import org.distorted.objectlib.main.ShapeOctahedron;
44
import org.distorted.objectlib.main.ShapeTetrahedron;
45 40
import org.distorted.objects.RubikObject;
46 41
import org.distorted.objects.RubikObjectList;
47 42

  
......
138 133
        }
139 134
      }
140 135

  
141
///////////////////////////////////////////////////////////////////////////////////////////////////
142

  
143
    @Override
144
    public void onAttachedToWindow()
145
      {
146
      super.onAttachedToWindow();
147

  
148
      if( mScreen==null ) mScreen = new ConfigScreen();
149
      mScreen.onAttachedToWindow(this,mObjectOrdinal);
150
      }
151

  
152 136
///////////////////////////////////////////////////////////////////////////////////////////////////
153 137
// do not avoid cutouts
154 138

  
......
194 178
      ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
195 179
      view.onResume();
196 180

  
181
      if( mScreen==null ) mScreen = new ConfigScreen();
182
      mScreen.onAttachedToWindow(this,mObjectOrdinal);
183

  
197 184
      if( mObjectOrdinal>=0 && mObjectOrdinal< RubikObjectList.getNumObjects() )
198 185
        {
199 186
        RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
......
240 227
// PUBLIC API
241 228
///////////////////////////////////////////////////////////////////////////////////////////////////
242 229

  
243
    public void changeObject(RubikObject object)
230
    public void changeObject(int ordinal)
244 231
      {
232
      mObjectOrdinal = ordinal;
233
      RubikObject object = RubikObjectList.getObject(ordinal);
245 234
      ConfigSurfaceView view = findViewById(R.id.configSurfaceView);
246 235
      ObjectControl control = view.getObjectControl();
247 236
      changeIfDifferent(object,control);
src/main/java/org/distorted/config/ConfigScreen.java
117 117
          if( act.getControl().isUINotBlocked() && mObjectOrdinal!=ordinal )
118 118
            {
119 119
            mObjectOrdinal = ordinal;
120
            act.changeObject(rubikObject);
120
            act.changeObject(mObjectOrdinal);
121 121
            mMovesText.setText(act.getString(R.string.mo_placeholder,mObjectOrdinal+1,numObjects));
122 122
            mPane.updatePane(act,mObjectOrdinal);
123 123
            }
......
241 241
    mObjectOrdinal--;
242 242
    if( mObjectOrdinal<0 ) mObjectOrdinal=numObjects-1;
243 243

  
244
    RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
245
    act.changeObject(object);
246

  
244
    act.changeObject(mObjectOrdinal);
247 245
    mPane.updatePane(act,mObjectOrdinal);
248 246
    }
249 247

  
......
254 252
    mObjectOrdinal++;
255 253
    if( mObjectOrdinal>=numObjects ) mObjectOrdinal=0;
256 254

  
257
    RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
258
    act.changeObject(object);
259

  
255
    act.changeObject(mObjectOrdinal);
260 256
    mPane.updatePane(act,mObjectOrdinal);
261 257
    }
262 258

  
src/main/java/org/distorted/tutorials/TutorialActivity.java
134 134
      {
135 135
      super.onAttachedToWindow();
136 136

  
137
      float width = getScreenWidthInPixels();
138

  
139
      LinearLayout viewR = findViewById(R.id.tutorialRightBar);
140
      ViewGroup.LayoutParams paramsR = viewR.getLayoutParams();
141
      paramsR.width = (int)(width*BAR_RATIO);
142
      viewR.setLayoutParams(paramsR);
143

  
144
      if( mScreen==null ) mScreen = new TutorialScreen();
145

  
146
      mScreen.createRightPane(this);
147

  
148
      WebView videoView = findViewById(R.id.tutorialVideoView);
149
      mWebView = new TutorialWebView(videoView);
150
      mWebView.load(URL+mURL);
137
      if( mWebView==null )
138
        {
139
        WebView videoView = findViewById(R.id.tutorialVideoView);
140
        mWebView = new TutorialWebView(videoView);
141
        mWebView.load(URL+mURL);
142
        }
151 143
      }
152 144

  
153 145
///////////////////////////////////////////////////////////////////////////////////////////////////
......
198 190
      TutorialSurfaceView view = findViewById(R.id.tutorialSurfaceView);
199 191
      view.onResume();
200 192

  
193
      float width = getScreenWidthInPixels();
194

  
195
      LinearLayout viewR = findViewById(R.id.tutorialRightBar);
196
      ViewGroup.LayoutParams paramsR = viewR.getLayoutParams();
197
      paramsR.width = (int)(width*BAR_RATIO);
198
      viewR.setLayoutParams(paramsR);
199

  
200
      if( mScreen==null ) mScreen = new TutorialScreen();
201

  
202
      mScreen.createRightPane(this);
203

  
201 204
      if( mWebView!=null ) mWebView.onResume();
202 205

  
203 206
      if( mObjectOrdinal>=0 && mObjectOrdinal< RubikObjectList.getNumObjects() )

Also available in: Unified diff