Project

General

Profile

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

magiccube / src / main / java / org / distorted / main / RubikPreRender.java @ 88a3e972

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.objectlib.helpers.BlockController;
46
import org.distorted.objectlib.helpers.MovesFinished;
47
import org.distorted.objectlib.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 )
463
      {
464
      mNewObject.createTexture();
465
      mNewObject.recomputeScaleFactor(width);
466
      }
467
    mScreenWidth = width;
468
    }
469

    
470
///////////////////////////////////////////////////////////////////////////////////////////////////
471

    
472
  void savePreferences(SharedPreferences.Editor editor)
473
    {
474
    if( mNewObject!=null )
475
      {
476
      mNewObject.savePreferences(editor);
477
      }
478
    }
479

    
480
///////////////////////////////////////////////////////////////////////////////////////////////////
481

    
482
  void restorePreferences(SharedPreferences preferences)
483
    {
484
    mPreferences = preferences;
485
    }
486

    
487
///////////////////////////////////////////////////////////////////////////////////////////////////
488

    
489
  void finishRotation(int nearestAngle)
490
    {
491
    mNearestAngle   = nearestAngle;
492
    mFinishRotation = true;
493
    }
494

    
495
///////////////////////////////////////////////////////////////////////////////////////////////////
496

    
497
  void changeObject(ObjectType object)
498
    {
499
    mChangeObject = true;
500
    mNextObject = object;
501
    }
502

    
503
///////////////////////////////////////////////////////////////////////////////////////////////////
504

    
505
  void setupObject(ObjectType object, int[][] moves)
506
    {
507
    mSetupObject= true;
508
    mNextObject = object;
509
    mNextMoves  = moves;
510
    }
511

    
512
///////////////////////////////////////////////////////////////////////////////////////////////////
513

    
514
  void setTextureMap(int cubit, int face, int newColor)
515
    {
516
    mSetTextureMap = true;
517

    
518
    mCubit    = cubit;
519
    mFace     = face;
520
    mNewColor = newColor;
521
    }
522

    
523
///////////////////////////////////////////////////////////////////////////////////////////////////
524

    
525
  public boolean isTouchBlocked()
526
    {
527
    return mTouchBlocked;
528
    }
529

    
530
///////////////////////////////////////////////////////////////////////////////////////////////////
531

    
532
  public boolean isUINotBlocked()
533
    {
534
    return !mUIBlocked;
535
    }
536

    
537
///////////////////////////////////////////////////////////////////////////////////////////////////
538

    
539
  public void blockEverything(int place)
540
    {
541
    mUIBlocked   = true;
542
    mTouchBlocked= true;
543
    mBlockController.touchBlocked(place);
544
    mBlockController.uiBlocked(place);
545
    }
546

    
547
///////////////////////////////////////////////////////////////////////////////////////////////////
548

    
549
  public void blockTouch(int place)
550
    {
551
    mTouchBlocked= true;
552
    mBlockController.touchBlocked(place);
553
    }
554

    
555
///////////////////////////////////////////////////////////////////////////////////////////////////
556

    
557
  public void unblockEverything()
558
    {
559
    mUIBlocked   = false;
560
    mTouchBlocked= false;
561
    mBlockController.touchUnblocked();
562
    mBlockController.uiUnblocked();
563
    }
564

    
565
///////////////////////////////////////////////////////////////////////////////////////////////////
566

    
567
  public void unblockTouch()
568
    {
569
    mTouchBlocked= false;
570
    mBlockController.touchUnblocked();
571
    }
572

    
573
///////////////////////////////////////////////////////////////////////////////////////////////////
574

    
575
  public void unblockUI()
576
    {
577
    mUIBlocked= false;
578
    mBlockController.uiUnblocked();
579
    }
580

    
581
///////////////////////////////////////////////////////////////////////////////////////////////////
582

    
583
  void setQuatOnNextRender()
584
    {
585
    mSetQuat = true;
586
    }
587

    
588
///////////////////////////////////////////////////////////////////////////////////////////////////
589

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

    
607
///////////////////////////////////////////////////////////////////////////////////////////////////
608
// PUBLIC API
609
///////////////////////////////////////////////////////////////////////////////////////////////////
610

    
611
  public void addRotation(MovesFinished listener, int axis, int rowBitmap, int angle, long duration)
612
    {
613
    mAddRotation = true;
614

    
615
    mAddActionListener    = listener;
616
    mAddRotationAxis      = axis;
617
    mAddRotationRowBitmap = rowBitmap;
618
    mAddRotationAngle     = angle;
619
    mAddRotationDuration  = duration;
620

    
621
    if( listener instanceof ScrambleEffect )
622
      {
623
      mDebug += (" (a "+axis+" "+rowBitmap+" "+angle+" "+(System.currentTimeMillis()-mDebugStartTime)+")");
624
      }
625
    }
626

    
627
///////////////////////////////////////////////////////////////////////////////////////////////////
628

    
629
  public void initializeObject(int[][] moves)
630
    {
631
    mInitializeObject = true;
632
    mNextMoves = moves;
633
    }
634

    
635
///////////////////////////////////////////////////////////////////////////////////////////////////
636

    
637
  public void scrambleObject(int num)
638
    {
639
    if( !mUIBlocked )
640
      {
641
      mScrambleObject = true;
642
      mScrambleObjectNum = num;
643
      mDebug = "";
644
      mDebugStartTime = System.currentTimeMillis();
645
      }
646
    }
647

    
648
///////////////////////////////////////////////////////////////////////////////////////////////////
649
// this starts the Solve Effect
650

    
651
  public void solveObject()
652
    {
653
    if( !mUIBlocked )
654
      {
655
      mSolveObject = true;
656
      }
657
    }
658

    
659
///////////////////////////////////////////////////////////////////////////////////////////////////
660
// this only sets the cubits state to solved
661

    
662
  public void solve()
663
    {
664
    mSolve = true;
665
    }
666

    
667
///////////////////////////////////////////////////////////////////////////////////////////////////
668

    
669
  public void resetAllTextureMaps()
670
    {
671
    mResetAllTextureMaps = true;
672
    }
673

    
674
///////////////////////////////////////////////////////////////////////////////////////////////////
675

    
676
  public TwistyObject getObject()
677
    {
678
    return mNewObject;
679
    }
680

    
681
///////////////////////////////////////////////////////////////////////////////////////////////////
682

    
683
  public TwistyObject getOldObject()
684
    {
685
    return mOldObject;
686
    }
687

    
688
///////////////////////////////////////////////////////////////////////////////////////////////////
689

    
690
  public int getNumScrambles()
691
    {
692
    return mScrambleObjectNum;
693
    }
694

    
695
///////////////////////////////////////////////////////////////////////////////////////////////////
696

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

    
721
          if( i==BaseEffect.Type.SCRAMBLE.ordinal() )
722
            {
723
            final RubikActivity act = (RubikActivity)mView.getContext();
724

    
725
            act.runOnUiThread(new Runnable()
726
              {
727
              @Override
728
              public void run()
729
                {
730
                ScreenList.switchScreen( act, ScreenList.READ);
731
                }
732
              });
733
            }
734

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

    
743
              reportRecord();
744
              requestReview();
745

    
746
              if( mIsNewRecord )
747
                {
748
                RubikDialogNewRecord dialog = new RubikDialogNewRecord();
749
                dialog.setArguments(bundle);
750
                dialog.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
751
                }
752
              else
753
                {
754
                RubikDialogSolved dialog = new RubikDialogSolved();
755
                dialog.setArguments(bundle);
756
                dialog.show( act.getSupportFragmentManager(), RubikDialogSolved.getDialogTag() );
757
                }
758

    
759
              act.runOnUiThread(new Runnable()
760
                {
761
                @Override
762
                public void run()
763
                  {
764
                  ScreenList.switchScreen( act, ScreenList.DONE);
765
                  }
766
                });
767
              }
768
            }
769

    
770
          break;
771
          }
772
        }
773
      }
774
    }
775
  }
(2-2/4)