Project

General

Profile

« Previous | Next » 

Revision e41e7dc3

Added by Leszek Koltunski about 4 years ago

Add the 'Solved' dialog.

View differences:

src/main/java/org/distorted/magic/RubikRenderer.java
21 21

  
22 22
import android.content.SharedPreferences;
23 23
import android.opengl.GLSurfaceView;
24
import android.os.Bundle;
24 25

  
26
import org.distorted.dialog.RubikDialogSolved;
25 27
import org.distorted.effect.BaseEffect;
26 28
import org.distorted.library.effect.VertexEffectSink;
27 29
import org.distorted.library.main.DistortedLibrary;
......
53 55
    private boolean mChangeObject, mSolveObject, mScrambleObject;
54 56
    private boolean mCanRotate, mCanDrag, mCanUI;
55 57
    private boolean mIsSolved;
58
    private boolean mIsNewRecord;
59
    private long mNewRecord;
56 60
    private RubikObject mOldObject, mNewObject;
57 61
    private int mScreenWidth, mScreenHeight;
58 62
    private SharedPreferences mPreferences;
......
265 269
         if( RubikState.getCurrentState()==RubikState.SOLV )
266 270
           {
267 271
           RubikStateSolving solving = (RubikStateSolving)RubikState.SOLV.getStateClass();
268
           solving.stopCounting();
272
           mNewRecord = solving.stopCounting((RubikActivity)mView.getContext());
273

  
274
           if( mNewRecord< 0 )
275
             {
276
             mNewRecord = -mNewRecord;
277
             mIsNewRecord = false;
278
             }
279
           else
280
             {
281
             mIsNewRecord = true;
282
             }
269 283
           }
270 284

  
271 285
         mCanDrag   = true;
......
383 397
                 }
384 398
               });
385 399
             }
400

  
401
           if( i==BaseEffect.Type.WIN.ordinal() )
402
             {
403
             if( RubikState.getCurrentState()==RubikState.SOLV )
404
               {
405
               final RubikActivity act = (RubikActivity)mView.getContext();
406

  
407
               if( mIsNewRecord )
408
                 {
409
                 RubikDialogSolved dialog = new RubikDialogSolved();
410

  
411
                 Bundle bundle = new Bundle();
412
                 bundle.putLong("time", mNewRecord );
413
                 dialog.setArguments(bundle);
414
                 dialog.show( act.getSupportFragmentManager(), null);
415
                 }
416
               else
417
                 {
418
                 RubikDialogSolved dialog = new RubikDialogSolved();
419

  
420
                 Bundle bundle = new Bundle();
421
                 bundle.putLong("time", mNewRecord );
422
                 dialog.setArguments(bundle);
423
                 dialog.show( act.getSupportFragmentManager(), null);
424
                 }
425
               }
426
             }
427

  
386 428
           break;
387 429
           }
388 430
         }

Also available in: Unified diff