Project

General

Profile

« Previous | Next » 

Revision 2f1b15da

Added by Leszek Koltunski almost 5 years ago

Corrections

View differences:

src/main/java/org/distorted/magic/RubikActivity.java
66 66
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
67 67
      view.onResume();
68 68
      restorePreferences();
69
      view.enterState(this, mCurrentState);
69
      view.switchState(this, mCurrentState);
70 70
      }
71 71
    
72 72
///////////////////////////////////////////////////////////////////////////////////////////////////
......
105 105
        if( mCurrentState!=null )
106 106
          {
107 107
          RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
108
          view.enterState(this, mCurrentState);
108
          view.switchState(this, mCurrentState);
109 109
          }
110 110
        else
111 111
          {
......
161 161
      {
162 162
      mCurrentState = RubikState.PLAY;
163 163
      RubikSurfaceView view = findViewById(R.id.rubikSurfaceView);
164
      view.enterState(this,mCurrentState);
164
      view.switchState(this,mCurrentState);
165 165
      }
166 166

  
167 167
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/magic/RubikSurfaceView.java
263 263

  
264 264
///////////////////////////////////////////////////////////////////////////////////////////////////
265 265

  
266
    void enterState(RubikActivity act, RubikState state)
266
    void switchState(RubikActivity act, RubikState state)
267 267
      {
268 268
      if( mCurrentState!=state )
269 269
        {
......
273 273
          case PLAY: enterPlayState(act); break;
274 274
          }
275 275

  
276
        if( mCurrentState==RubikState.PLAY )
276
        if( mCurrentState!=null )
277 277
          {
278
          mPickerValue = mPicker.getValue();
279
          }
280
        if( mCurrentState==RubikState.MAIN )
281
          {
282
          FragmentManager mana = act.getSupportFragmentManager();
283
          RubikDialogMain diag = (RubikDialogMain) mana.findFragmentByTag(RubikDialogMain.getDialogTag());
284

  
285
          if( diag!=null )
286
            {
287
            diag.dismiss();
288
            }
289
          else
278
          switch(mCurrentState)
290 279
            {
291
            android.util.Log.e("act", "cannot find main dialog!");
292
            }
293
          }
294
        if( state==RubikState.MAIN )
295
          {
296
          FragmentManager mana = act.getSupportFragmentManager();
297
          RubikDialogMain diag = (RubikDialogMain) mana.findFragmentByTag(RubikDialogMain.getDialogTag());
298

  
299
          if( diag==null )
300
            {
301
            RubikDialogMain diag2 = new RubikDialogMain();
302
            diag2.show( mana, RubikDialogMain.getDialogTag() );
280
            case MAIN: leaveMainState(act); break;
281
            case PLAY: leavePlayState(act); break;
303 282
            }
304 283
          }
305 284

  
......
311 290
        }
312 291
      }
313 292

  
293
///////////////////////////////////////////////////////////////////////////////////////////////////
294

  
295
    private void leaveMainState(RubikActivity act)
296
      {
297
      FragmentManager mana = act.getSupportFragmentManager();
298
      RubikDialogMain diag = (RubikDialogMain) mana.findFragmentByTag(RubikDialogMain.getDialogTag());
299

  
300
      if( diag!=null )
301
        {
302
        diag.dismiss();
303
        }
304
      else
305
        {
306
        android.util.Log.e("act", "cannot find main dialog!");
307
        }
308
      }
309

  
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311

  
312
    private void leavePlayState(RubikActivity act)
313
      {
314
      mPickerValue = mPicker.getValue();
315
      }
316

  
314 317
///////////////////////////////////////////////////////////////////////////////////////////////////
315 318

  
316 319
    private void enterMainState(RubikActivity act)
317 320
      {
321
      FragmentManager mana = act.getSupportFragmentManager();
322
      RubikDialogMain diag = (RubikDialogMain) mana.findFragmentByTag(RubikDialogMain.getDialogTag());
323

  
324
      if( diag==null )
325
        {
326
        RubikDialogMain diag2 = new RubikDialogMain();
327
        diag2.show( mana, RubikDialogMain.getDialogTag() );
328
        }
329

  
318 330
      LayoutInflater inflater = act.getLayoutInflater();
319 331

  
320 332
      // TOP ////////////////////////////

Also available in: Unified diff