Project

General

Profile

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

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

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.getObjectList()!=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.getObjectList()!=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

    
326
    if( mNewObject!=null ) mNewObject.resetAllTextureMaps();
327
    }
328

    
329
///////////////////////////////////////////////////////////////////////////////////////////////////
330

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

    
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

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

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

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

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

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

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

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

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

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

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

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

    
426
///////////////////////////////////////////////////////////////////////////////////////////////////
427

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

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

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

    
450
///////////////////////////////////////////////////////////////////////////////////////////////////
451
//
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453

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

    
459
///////////////////////////////////////////////////////////////////////////////////////////////////
460

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

    
467
///////////////////////////////////////////////////////////////////////////////////////////////////
468

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

    
477
///////////////////////////////////////////////////////////////////////////////////////////////////
478

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

    
484
///////////////////////////////////////////////////////////////////////////////////////////////////
485

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

    
492
///////////////////////////////////////////////////////////////////////////////////////////////////
493

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

    
500
///////////////////////////////////////////////////////////////////////////////////////////////////
501

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

    
509
///////////////////////////////////////////////////////////////////////////////////////////////////
510

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

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

    
520
///////////////////////////////////////////////////////////////////////////////////////////////////
521

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

    
527
///////////////////////////////////////////////////////////////////////////////////////////////////
528

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

    
534
///////////////////////////////////////////////////////////////////////////////////////////////////
535

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

    
544
///////////////////////////////////////////////////////////////////////////////////////////////////
545

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

    
552
///////////////////////////////////////////////////////////////////////////////////////////////////
553

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

    
562
///////////////////////////////////////////////////////////////////////////////////////////////////
563

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

    
570
///////////////////////////////////////////////////////////////////////////////////////////////////
571

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

    
578
///////////////////////////////////////////////////////////////////////////////////////////////////
579

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

    
585
///////////////////////////////////////////////////////////////////////////////////////////////////
586

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

    
604
///////////////////////////////////////////////////////////////////////////////////////////////////
605
// PUBLIC API
606
///////////////////////////////////////////////////////////////////////////////////////////////////
607

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

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

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

    
624
///////////////////////////////////////////////////////////////////////////////////////////////////
625

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

    
632
///////////////////////////////////////////////////////////////////////////////////////////////////
633

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

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

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

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

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

    
664
///////////////////////////////////////////////////////////////////////////////////////////////////
665

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

    
671
///////////////////////////////////////////////////////////////////////////////////////////////////
672

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

    
678
///////////////////////////////////////////////////////////////////////////////////////////////////
679

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

    
685
///////////////////////////////////////////////////////////////////////////////////////////////////
686

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

    
692
///////////////////////////////////////////////////////////////////////////////////////////////////
693

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

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

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

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

    
740
              reportRecord();
741
              requestReview();
742

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

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

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