Project

General

Profile

Download (23.8 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / main / RubikPreRender.java @ c4175d85

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube 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
// Magic Cube 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 Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.main;
21

    
22
import android.content.Context;
23
import android.content.SharedPreferences;
24
import android.content.res.Resources;
25
import android.os.Bundle;
26

    
27
import androidx.annotation.NonNull;
28

    
29
import com.google.android.play.core.review.ReviewInfo;
30
import com.google.android.play.core.review.ReviewManager;
31
import com.google.android.play.core.review.ReviewManagerFactory;
32
import com.google.android.play.core.tasks.OnCompleteListener;
33
import com.google.android.play.core.tasks.OnFailureListener;
34
import com.google.android.play.core.tasks.Task;
35
import com.google.firebase.analytics.FirebaseAnalytics;
36

    
37
import org.distorted.objectlib.main.TwistyObject;
38
import org.distorted.objectlib.main.ObjectType;
39

    
40
import org.distorted.dialogs.RubikDialogNewRecord;
41
import org.distorted.dialogs.RubikDialogSolved;
42
import org.distorted.effects.BaseEffect;
43
import org.distorted.effects.EffectController;
44
import org.distorted.effects.scramble.ScrambleEffect;
45
import org.distorted.helpers.BlockController;
46
import org.distorted.helpers.MovesFinished;
47
import org.distorted.helpers.TwistyPreRender;
48
import org.distorted.network.RubikScores;
49
import org.distorted.screens.RubikScreenPlay;
50
import org.distorted.screens.ScreenList;
51
import org.distorted.screens.RubikScreenSolving;
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
public class RubikPreRender implements EffectController, TwistyPreRender
56
  {
57
  private final RubikSurfaceView mView;
58
  private boolean mFinishRotation, mRemoveRotation, mRemovePatternRotation, mAddRotation,
59
                  mSetQuat, mChangeObject, mSetupObject, mSolveObject, mScrambleObject,
60
                  mInitializeObject, mSetTextureMap, mResetAllTextureMaps, mSolve;
61
  private boolean mUIBlocked, mTouchBlocked;
62
  private boolean mIsSolved;
63
  private ObjectType mNextObject;
64
  private long mRotationFinishedID;
65
  private final long[] mEffectID;
66
  private boolean mIsNewRecord;
67
  private long mNewRecord;
68
  private int mScreenWidth;
69
  private SharedPreferences mPreferences;
70
  private int[][] mNextMoves;
71
  private TwistyObject mOldObject, mNewObject;
72
  private int mScrambleObjectNum;
73
  private int mAddRotationAxis, mAddRotationRowBitmap, mAddRotationAngle;
74
  private long mAddRotationDuration;
75
  private MovesFinished mAddActionListener;
76
  private long mAddRotationID, mRemoveRotationID;
77
  private int mCubit, mFace, mNewColor;
78
  private int mNearestAngle;
79
  private String mDebug;
80
  private long mDebugStartTime;
81
  private final BlockController mBlockController;
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

    
85
  RubikPreRender(RubikSurfaceView view)
86
    {
87
    mView = view;
88

    
89
    mFinishRotation       = false;
90
    mRemoveRotation       = false;
91
    mRemovePatternRotation= false;
92
    mAddRotation          = false;
93
    mSetQuat              = false;
94
    mChangeObject         = false;
95
    mSetupObject          = false;
96
    mSolveObject          = false;
97
    mSolve                = false;
98
    mScrambleObject       = false;
99

    
100
    mOldObject = null;
101
    mNewObject = null;
102

    
103
    mScreenWidth = 0;
104
    mScrambleObjectNum = 0;
105

    
106
    mEffectID = new long[BaseEffect.Type.LENGTH];
107

    
108
    mDebug = "";
109

    
110
    RubikActivity act = (RubikActivity)mView.getContext();
111
    mBlockController = new BlockController(act);
112
    unblockEverything();
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

    
117
  private void createObjectNow(ObjectType object, int[][] moves)
118
    {
119
    boolean firstTime = (mNewObject==null);
120

    
121
    if( mOldObject!=null ) mOldObject.releaseResources();
122
    mOldObject = mNewObject;
123

    
124
    Context con = mView.getContext();
125
    Resources res = con.getResources();
126

    
127
    mNewObject = object.create(mView.getQuat(), moves, res, mScreenWidth);
128

    
129
    if( mNewObject!=null )
130
      {
131
      mView.setMovement(mNewObject.getMovement());
132
      if( firstTime ) mNewObject.restorePreferences(mPreferences);
133
      mIsSolved = mNewObject.isSolved();
134
      }
135
    }
136

    
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138
// do all 'adjustable' effects (SizeChange, Solve, Scramble)
139

    
140
  private void doEffectNow(BaseEffect.Type type)
141
    {
142
    try
143
      {
144
      int index = type.ordinal();
145
      mEffectID[index] = type.startEffect(mView.getRenderer().getScreen(),this);
146
      }
147
    catch( Exception ex )
148
      {
149
      android.util.Log.e("renderer", "exception starting effect: "+ex.getMessage());
150
      unblockEverything();
151
      }
152
    }
153

    
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

    
156
  private void removeRotationNow()
157
    {
158
    mRemoveRotation=false;
159
    mNewObject.removeRotationNow();
160

    
161
    boolean solved = mNewObject.isSolved();
162

    
163
    if( solved && !mIsSolved )
164
      {
165
      if( ScreenList.getCurrentScreen()== ScreenList.SOLV )
166
        {
167
        RubikScreenSolving solving = (RubikScreenSolving) ScreenList.SOLV.getScreenClass();
168
        mNewRecord = solving.getRecord();
169

    
170
        if( mNewRecord< 0 )
171
          {
172
          mNewRecord = -mNewRecord;
173
          mIsNewRecord = false;
174
          }
175
        else
176
          {
177
          mIsNewRecord = true;
178
          }
179
        }
180

    
181
      unblockEverything();
182
      doEffectNow( BaseEffect.Type.WIN );
183
      }
184
    else
185
      {
186
      unblockEverything();
187
      }
188

    
189
    mIsSolved = solved;
190
    }
191

    
192
///////////////////////////////////////////////////////////////////////////////////////////////////
193

    
194
  private void removeRotation()
195
    {
196
    mRemoveRotation = true;
197
    }
198

    
199
///////////////////////////////////////////////////////////////////////////////////////////////////
200

    
201
  private void removePatternRotation()
202
    {
203
    mRemovePatternRotation = true;
204
    }
205

    
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207

    
208
  private void removePatternRotationNow()
209
    {
210
    mRemovePatternRotation=false;
211
    mNewObject.removeRotationNow();
212
    mAddActionListener.onActionFinished(mRemoveRotationID);
213
    }
214

    
215
///////////////////////////////////////////////////////////////////////////////////////////////////
216

    
217
  private void addRotationNow()
218
    {
219
    mAddRotation = false;
220
    mAddRotationID = mNewObject.addNewRotation( mAddRotationAxis, mAddRotationRowBitmap,
221
                                                mAddRotationAngle, mAddRotationDuration, this);
222

    
223
    if( mAddRotationID==0 ) // failed to add effect - should never happen
224
      {
225
      unblockEverything();
226
      }
227
    }
228

    
229
///////////////////////////////////////////////////////////////////////////////////////////////////
230

    
231
  private void finishRotationNow()
232
    {
233
    mFinishRotation = false;
234
    blockEverything(BlockController.RUBIK_PLACE_0);
235
    mRotationFinishedID = mNewObject.finishRotationNow(this, mNearestAngle);
236

    
237
    if( mRotationFinishedID==0 ) // failed to add effect - should never happen
238
      {
239
      unblockEverything();
240
      }
241
    }
242

    
243
///////////////////////////////////////////////////////////////////////////////////////////////////
244

    
245
  private void changeObjectNow()
246
    {
247
    mChangeObject = false;
248

    
249
    if ( mNewObject==null || mNewObject.getObjectType()!=mNextObject )
250
      {
251
      blockEverything(BlockController.RUBIK_PLACE_1);
252
      createObjectNow(mNextObject, null);
253
      doEffectNow( BaseEffect.Type.SIZECHANGE );
254
      }
255
    }
256

    
257
///////////////////////////////////////////////////////////////////////////////////////////////////
258

    
259
  private void setupObjectNow()
260
    {
261
    mSetupObject = false;
262

    
263
    if ( mNewObject==null || mNewObject.getObjectType()!=mNextObject)
264
      {
265
      blockEverything(BlockController.RUBIK_PLACE_2);
266
      createObjectNow(mNextObject, mNextMoves);
267
      doEffectNow( BaseEffect.Type.SIZECHANGE );
268
      }
269
    else
270
      {
271
      mNewObject.initializeObject(mNextMoves);
272
      }
273
    }
274

    
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276

    
277
  private void scrambleObjectNow()
278
    {
279
    mScrambleObject = false;
280
    mIsSolved       = false;
281
    blockEverything(BlockController.RUBIK_PLACE_3);
282
    RubikScores.getInstance().incrementNumPlays();
283
    doEffectNow( BaseEffect.Type.SCRAMBLE );
284
    }
285

    
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287

    
288
  private void solveObjectNow()
289
    {
290
    mSolveObject = false;
291
    blockEverything(BlockController.RUBIK_PLACE_4);
292
    doEffectNow( BaseEffect.Type.SOLVE );
293
    }
294

    
295
///////////////////////////////////////////////////////////////////////////////////////////////////
296

    
297
  private void solveNow()
298
    {
299
    mSolve = false;
300
    mNewObject.solve();
301
    }
302

    
303
///////////////////////////////////////////////////////////////////////////////////////////////////
304

    
305
  private void initializeObjectNow()
306
    {
307
    mInitializeObject = false;
308
    mNewObject.initializeObject(mNextMoves);
309
    }
310

    
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312

    
313
  private void setTextureMapNow()
314
    {
315
    mSetTextureMap = false;
316

    
317
    if( mNewObject!=null ) mNewObject.setTextureMap(mCubit,mFace,mNewColor);
318
    }
319

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321

    
322
  private void resetAllTextureMapsNow()
323
    {
324
    mResetAllTextureMaps = false;
325
    if( mNewObject!=null ) mNewObject.resetAllTextureMaps();
326
    }
327

    
328
///////////////////////////////////////////////////////////////////////////////////////////////////
329

    
330
  private void setQuatNow()
331
    {
332
    mSetQuat = false;
333
    mView.setQuat();
334
    }
335

    
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

    
338
  private void reportRecord()
339
    {
340
    RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
341
    RubikScores scores = RubikScores.getInstance();
342

    
343
    int object      = play.getObject();
344
    int level       = play.getLevel();
345
    ObjectType list = ObjectType.getObject(object);
346
    String name     = scores.getName();
347

    
348
    String record = list.name()+" level "+level+" time "+mNewRecord+" isNew: "+mIsNewRecord+" scrambleNum: "+mScrambleObjectNum;
349

    
350
    if( BuildConfig.DEBUG )
351
       {
352
       android.util.Log.e("pre", mDebug);
353
       android.util.Log.e("pre", name);
354
       android.util.Log.e("pre", record);
355
       }
356
    else
357
      {
358
      final RubikActivity act = (RubikActivity)mView.getContext();
359
      FirebaseAnalytics analytics = act.getAnalytics();
360

    
361
      if( analytics!=null )
362
        {
363
        Bundle bundle = new Bundle();
364
        bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, mDebug);
365
        bundle.putString(FirebaseAnalytics.Param.CHARACTER, name);
366
        bundle.putString(FirebaseAnalytics.Param.LEVEL, record);
367
        analytics.logEvent(FirebaseAnalytics.Event.LEVEL_UP, bundle);
368
        }
369
      }
370
    }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373

    
374
  private void requestReview()
375
    {
376
    final RubikScores scores = RubikScores.getInstance();
377
    int numWins = scores.incrementNumWins();
378

    
379
    if( numWins==7 || numWins==30 || numWins==100 || numWins==200)
380
      {
381
      final long timeBegin = System.currentTimeMillis();
382
      final RubikActivity act = (RubikActivity)mView.getContext();
383
      final ReviewManager manager = ReviewManagerFactory.create(act);
384
      Task<ReviewInfo> request = manager.requestReviewFlow();
385

    
386
      request.addOnCompleteListener(new OnCompleteListener<ReviewInfo>()
387
        {
388
        @Override
389
        public void onComplete (@NonNull Task<ReviewInfo> task)
390
          {
391
          if (task.isSuccessful())
392
            {
393
            final String name = scores.getName();
394
            ReviewInfo reviewInfo = task.getResult();
395
            Task<Void> flow = manager.launchReviewFlow(act, reviewInfo);
396

    
397
            flow.addOnFailureListener(new OnFailureListener()
398
              {
399
              @Override
400
              public void onFailure(Exception e)
401
                {
402
                analyticsReport(act,"Failed", name, timeBegin);
403
                }
404
              });
405

    
406
            flow.addOnCompleteListener(new OnCompleteListener<Void>()
407
              {
408
              @Override
409
              public void onComplete(@NonNull Task<Void> task)
410
                {
411
                analyticsReport(act,"Complete", name, timeBegin);
412
                }
413
              });
414
            }
415
          else
416
            {
417
            String name = scores.getName();
418
            analyticsReport(act,"Not Successful", name, timeBegin);
419
            }
420
          }
421
        });
422
      }
423
    }
424

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426

    
427
  private void analyticsReport(RubikActivity act, String message, String name, long timeBegin)
428
    {
429
    long elapsed = System.currentTimeMillis() - timeBegin;
430
    String msg = message+" startTime: "+timeBegin+" elapsed: "+elapsed+" name: "+name;
431

    
432
    if( BuildConfig.DEBUG )
433
       {
434
       android.util.Log.d("pre", msg);
435
       }
436
    else
437
      {
438
      FirebaseAnalytics analytics = act.getAnalytics();
439

    
440
      if( analytics!=null )
441
        {
442
        Bundle bundle = new Bundle();
443
        bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, msg);
444
        analytics.logEvent(FirebaseAnalytics.Event.SHARE, bundle);
445
        }
446
      }
447
    }
448

    
449
///////////////////////////////////////////////////////////////////////////////////////////////////
450
//
451
///////////////////////////////////////////////////////////////////////////////////////////////////
452

    
453
  void rememberMove(int axis, int row, int angle)
454
    {
455
    mDebug += (" (m "+axis+" "+(1<<row)+" "+angle+" "+(System.currentTimeMillis()-mDebugStartTime)+")");
456
    }
457

    
458
///////////////////////////////////////////////////////////////////////////////////////////////////
459

    
460
  void setScreenSize(int width)
461
    {
462
    if( mNewObject!=null ) mNewObject.recomputeScaleFactor(width);
463
    mScreenWidth = width;
464
    }
465

    
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467

    
468
  void savePreferences(SharedPreferences.Editor editor)
469
    {
470
    if( mNewObject!=null )
471
      {
472
      mNewObject.savePreferences(editor);
473
      }
474
    }
475

    
476
///////////////////////////////////////////////////////////////////////////////////////////////////
477

    
478
  void restorePreferences(SharedPreferences preferences)
479
    {
480
    mPreferences = preferences;
481
    }
482

    
483
///////////////////////////////////////////////////////////////////////////////////////////////////
484

    
485
  void finishRotation(int nearestAngle)
486
    {
487
    mNearestAngle   = nearestAngle;
488
    mFinishRotation = true;
489
    }
490

    
491
///////////////////////////////////////////////////////////////////////////////////////////////////
492

    
493
  void changeObject(ObjectType object)
494
    {
495
    mChangeObject = true;
496
    mNextObject = object;
497
    }
498

    
499
///////////////////////////////////////////////////////////////////////////////////////////////////
500

    
501
  void setupObject(ObjectType object, int[][] moves)
502
    {
503
    mSetupObject= true;
504
    mNextObject = object;
505
    mNextMoves  = moves;
506
    }
507

    
508
///////////////////////////////////////////////////////////////////////////////////////////////////
509

    
510
  void setTextureMap(int cubit, int face, int newColor)
511
    {
512
    mSetTextureMap = true;
513

    
514
    mCubit    = cubit;
515
    mFace     = face;
516
    mNewColor = newColor;
517
    }
518

    
519
///////////////////////////////////////////////////////////////////////////////////////////////////
520

    
521
  public boolean isTouchBlocked()
522
    {
523
    return mTouchBlocked;
524
    }
525

    
526
///////////////////////////////////////////////////////////////////////////////////////////////////
527

    
528
  public boolean isUINotBlocked()
529
    {
530
    return !mUIBlocked;
531
    }
532

    
533
///////////////////////////////////////////////////////////////////////////////////////////////////
534

    
535
  public void blockEverything(int place)
536
    {
537
    mUIBlocked   = true;
538
    mTouchBlocked= true;
539
    mBlockController.touchBlocked(place);
540
    mBlockController.uiBlocked(place);
541
    }
542

    
543
///////////////////////////////////////////////////////////////////////////////////////////////////
544

    
545
  public void blockTouch(int place)
546
    {
547
    mTouchBlocked= true;
548
    mBlockController.touchBlocked(place);
549
    }
550

    
551
///////////////////////////////////////////////////////////////////////////////////////////////////
552

    
553
  public void unblockEverything()
554
    {
555
    mUIBlocked   = false;
556
    mTouchBlocked= false;
557
    mBlockController.touchUnblocked();
558
    mBlockController.uiUnblocked();
559
    }
560

    
561
///////////////////////////////////////////////////////////////////////////////////////////////////
562

    
563
  public void unblockTouch()
564
    {
565
    mTouchBlocked= false;
566
    mBlockController.touchUnblocked();
567
    }
568

    
569
///////////////////////////////////////////////////////////////////////////////////////////////////
570

    
571
  public void unblockUI()
572
    {
573
    mUIBlocked= false;
574
    mBlockController.uiUnblocked();
575
    }
576

    
577
///////////////////////////////////////////////////////////////////////////////////////////////////
578

    
579
  void setQuatOnNextRender()
580
    {
581
    mSetQuat = true;
582
    }
583

    
584
///////////////////////////////////////////////////////////////////////////////////////////////////
585

    
586
  void preRender()
587
    {
588
    if( mSolve                 ) solveNow();
589
    if( mSetQuat               ) setQuatNow();
590
    if( mFinishRotation        ) finishRotationNow();
591
    if( mRemoveRotation        ) removeRotationNow();
592
    if( mRemovePatternRotation ) removePatternRotationNow();
593
    if( mChangeObject          ) changeObjectNow();
594
    if( mSetupObject           ) setupObjectNow();
595
    if( mSolveObject           ) solveObjectNow();
596
    if( mScrambleObject        ) scrambleObjectNow();
597
    if( mAddRotation           ) addRotationNow();
598
    if( mInitializeObject      ) initializeObjectNow();
599
    if( mResetAllTextureMaps   ) resetAllTextureMapsNow();
600
    if( mSetTextureMap         ) setTextureMapNow();
601
    }
602

    
603
///////////////////////////////////////////////////////////////////////////////////////////////////
604
// PUBLIC API
605
///////////////////////////////////////////////////////////////////////////////////////////////////
606

    
607
  public void addRotation(MovesFinished listener, int axis, int rowBitmap, int angle, long duration)
608
    {
609
    mAddRotation = true;
610

    
611
    mAddActionListener    = listener;
612
    mAddRotationAxis      = axis;
613
    mAddRotationRowBitmap = rowBitmap;
614
    mAddRotationAngle     = angle;
615
    mAddRotationDuration  = duration;
616

    
617
    if( listener instanceof ScrambleEffect )
618
      {
619
      mDebug += (" (a "+axis+" "+rowBitmap+" "+angle+" "+(System.currentTimeMillis()-mDebugStartTime)+")");
620
      }
621
    }
622

    
623
///////////////////////////////////////////////////////////////////////////////////////////////////
624

    
625
  public void initializeObject(int[][] moves)
626
    {
627
    mInitializeObject = true;
628
    mNextMoves = moves;
629
    }
630

    
631
///////////////////////////////////////////////////////////////////////////////////////////////////
632

    
633
  public void scrambleObject(int num)
634
    {
635
    if( !mUIBlocked )
636
      {
637
      mScrambleObject = true;
638
      mScrambleObjectNum = num;
639
      mDebug = "";
640
      mDebugStartTime = System.currentTimeMillis();
641
      }
642
    }
643

    
644
///////////////////////////////////////////////////////////////////////////////////////////////////
645
// this starts the Solve Effect
646

    
647
  public void solveObject()
648
    {
649
    if( !mUIBlocked )
650
      {
651
      mSolveObject = true;
652
      }
653
    }
654

    
655
///////////////////////////////////////////////////////////////////////////////////////////////////
656
// this only sets the cubits state to solved
657

    
658
  public void solve()
659
    {
660
    mSolve = true;
661
    }
662

    
663
///////////////////////////////////////////////////////////////////////////////////////////////////
664

    
665
  public void resetAllTextureMaps()
666
    {
667
    mResetAllTextureMaps = true;
668
    }
669

    
670
///////////////////////////////////////////////////////////////////////////////////////////////////
671

    
672
  public TwistyObject getObject()
673
    {
674
    return mNewObject;
675
    }
676

    
677
///////////////////////////////////////////////////////////////////////////////////////////////////
678

    
679
  public TwistyObject getOldObject()
680
    {
681
    return mOldObject;
682
    }
683

    
684
///////////////////////////////////////////////////////////////////////////////////////////////////
685

    
686
  public int getNumScrambles()
687
    {
688
    return mScrambleObjectNum;
689
    }
690

    
691
///////////////////////////////////////////////////////////////////////////////////////////////////
692

    
693
  public void effectFinished(final long effectID)
694
    {
695
    if( effectID == mRotationFinishedID )
696
      {
697
      mRotationFinishedID = 0;
698
      removeRotation();
699
      }
700
    else if( effectID == mAddRotationID )
701
      {
702
      mAddRotationID = 0;
703
      mRemoveRotationID = effectID;
704
      removePatternRotation();
705
      }
706
    else
707
      {
708
      for(int i=0; i<BaseEffect.Type.LENGTH; i++)
709
        {
710
        if( effectID == mEffectID[i] )
711
          {
712
          if( i!=BaseEffect.Type.WIN.ordinal() )
713
            {
714
            unblockEverything();
715
            }
716

    
717
          if( i==BaseEffect.Type.SCRAMBLE.ordinal() )
718
            {
719
            final RubikActivity act = (RubikActivity)mView.getContext();
720

    
721
            act.runOnUiThread(new Runnable()
722
              {
723
              @Override
724
              public void run()
725
                {
726
                ScreenList.switchScreen( act, ScreenList.READ);
727
                }
728
              });
729
            }
730

    
731
          if( i==BaseEffect.Type.WIN.ordinal() )
732
            {
733
            if( ScreenList.getCurrentScreen()== ScreenList.SOLV )
734
              {
735
              final RubikActivity act = (RubikActivity)mView.getContext();
736
              Bundle bundle = new Bundle();
737
              bundle.putLong("time", mNewRecord );
738

    
739
              reportRecord();
740
              requestReview();
741

    
742
              if( mIsNewRecord )
743
                {
744
                RubikDialogNewRecord dialog = new RubikDialogNewRecord();
745
                dialog.setArguments(bundle);
746
                dialog.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
747
                }
748
              else
749
                {
750
                RubikDialogSolved dialog = new RubikDialogSolved();
751
                dialog.setArguments(bundle);
752
                dialog.show( act.getSupportFragmentManager(), RubikDialogSolved.getDialogTag() );
753
                }
754

    
755
              act.runOnUiThread(new Runnable()
756
                {
757
                @Override
758
                public void run()
759
                  {
760
                  ScreenList.switchScreen( act, ScreenList.DONE);
761
                  }
762
                });
763
              }
764
            }
765

    
766
          break;
767
          }
768
        }
769
      }
770
    }
771
  }
(2-2/4)