Project

General

Profile

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

magiccube / src / main / java / org / distorted / main / RubikPreRender.java @ 55e6be1d

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.dialogs.RubikDialogNewRecord;
38
import org.distorted.dialogs.RubikDialogSolved;
39
import org.distorted.effects.BaseEffect;
40
import org.distorted.effects.EffectController;
41
import org.distorted.effects.scramble.ScrambleEffect;
42
import org.distorted.helpers.MovesFinished;
43
import org.distorted.helpers.TwistyPreRender;
44
import org.distorted.objects.TwistyObject;
45
import org.distorted.objects.ObjectList;
46
import org.distorted.network.RubikScores;
47
import org.distorted.screens.RubikScreenPlay;
48
import org.distorted.screens.ScreenList;
49
import org.distorted.screens.RubikScreenSolving;
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

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

    
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82

    
83
  RubikPreRender(RubikSurfaceView view)
84
    {
85
    mView = view;
86

    
87
    mFinishRotation       = false;
88
    mRemoveRotation       = false;
89
    mRemovePatternRotation= false;
90
    mAddRotation          = false;
91
    mSetQuat              = false;
92
    mChangeObject         = false;
93
    mSetupObject          = false;
94
    mSolveObject          = false;
95
    mScrambleObject       = false;
96

    
97
    unblockEverything();
98

    
99
    mOldObject = null;
100
    mNewObject = null;
101

    
102
    mScreenWidth = 0;
103
    mScrambleObjectNum = 0;
104

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

    
107
    mDebug = "";
108
    }
109

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

    
112
  private void createObjectNow(ObjectList object, int size, int[][] moves)
113
    {
114
    boolean firstTime = (mNewObject==null);
115

    
116
    if( mOldObject!=null ) mOldObject.releaseResources();
117
    mOldObject = mNewObject;
118

    
119
    Context con = mView.getContext();
120
    Resources res = con.getResources();
121

    
122
    mNewObject = object.create(size, mView.getQuat(), moves, res, mScreenWidth);
123

    
124
    if( mNewObject!=null )
125
      {
126
      mNewObject.createTexture();
127
      mView.setMovement(object.getObjectMovementClass());
128

    
129
      if( firstTime ) mNewObject.restorePreferences(mPreferences);
130

    
131
      if( mScreenWidth!=0 )
132
        {
133
        mNewObject.recomputeScaleFactor(mScreenWidth);
134
        }
135

    
136
      mIsSolved = mNewObject.isSolved();
137
      }
138
    }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
// do all 'adjustable' effects (SizeChange, Solve, Scramble)
142

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

    
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158

    
159
  private void removeRotationNow()
160
    {
161
    mRemoveRotation=false;
162
    mNewObject.removeRotationNow();
163

    
164
    boolean solved = mNewObject.isSolved();
165

    
166
    if( solved && !mIsSolved )
167
      {
168
      if( ScreenList.getCurrentScreen()== ScreenList.SOLV )
169
        {
170
        RubikScreenSolving solving = (RubikScreenSolving) ScreenList.SOLV.getScreenClass();
171
        mNewRecord = solving.getRecord();
172

    
173
        if( mNewRecord< 0 )
174
          {
175
          mNewRecord = -mNewRecord;
176
          mIsNewRecord = false;
177
          }
178
        else
179
          {
180
          mIsNewRecord = true;
181
          }
182
        }
183

    
184
      unblockEverything();
185
      doEffectNow( BaseEffect.Type.WIN );
186
      }
187
    else
188
      {
189
      unblockEverything();
190
      }
191

    
192
    mIsSolved = solved;
193
    }
194

    
195
///////////////////////////////////////////////////////////////////////////////////////////////////
196

    
197
  private void removeRotation()
198
    {
199
    mRemoveRotation = true;
200
    }
201

    
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

    
204
  private void removePatternRotation()
205
    {
206
    mRemovePatternRotation = true;
207
    }
208

    
209
///////////////////////////////////////////////////////////////////////////////////////////////////
210

    
211
  private void removePatternRotationNow()
212
    {
213
    mRemovePatternRotation=false;
214
    mNewObject.removeRotationNow();
215
    mAddActionListener.onActionFinished(mRemoveRotationID);
216
    }
217

    
218
///////////////////////////////////////////////////////////////////////////////////////////////////
219

    
220
  private void addRotationNow()
221
    {
222
    mAddRotation = false;
223
    mAddRotationID = mNewObject.addNewRotation( mAddRotationAxis, mAddRotationRowBitmap,
224
                                                mAddRotationAngle, mAddRotationDuration, this);
225

    
226
    if( mAddRotationID==0 ) // failed to add effect - should never happen
227
      {
228
      unblockEverything();
229
      }
230
    }
231

    
232
///////////////////////////////////////////////////////////////////////////////////////////////////
233

    
234
  private void finishRotationNow()
235
    {
236
    mFinishRotation = false;
237
    blockEverything();
238
    mRotationFinishedID = mNewObject.finishRotationNow(this, mNearestAngle);
239

    
240
    if( mRotationFinishedID==0 ) // failed to add effect - should never happen
241
      {
242
      unblockEverything();
243
      }
244
    }
245

    
246
///////////////////////////////////////////////////////////////////////////////////////////////////
247

    
248
  private void changeObjectNow()
249
    {
250
    mChangeObject = false;
251

    
252
    if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getNumLayers()!=mNextSize)
253
      {
254
      blockEverything();
255
      createObjectNow(mNextObject, mNextSize, null);
256
      doEffectNow( BaseEffect.Type.SIZECHANGE );
257
      }
258
    }
259

    
260
///////////////////////////////////////////////////////////////////////////////////////////////////
261

    
262
  private void setupObjectNow()
263
    {
264
    mSetupObject = false;
265

    
266
    if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getNumLayers()!=mNextSize)
267
      {
268
      blockEverything();
269
      createObjectNow(mNextObject, mNextSize, mNextMoves);
270
      doEffectNow( BaseEffect.Type.SIZECHANGE );
271
      }
272
    else
273
      {
274
      mNewObject.initializeObject(mNextMoves);
275
      }
276
    }
277

    
278
///////////////////////////////////////////////////////////////////////////////////////////////////
279

    
280
  private void scrambleObjectNow()
281
    {
282
    mScrambleObject = false;
283
    mIsSolved       = false;
284
    blockEverything();
285
    RubikScores.getInstance().incrementNumPlays();
286
    doEffectNow( BaseEffect.Type.SCRAMBLE );
287
    }
288

    
289
///////////////////////////////////////////////////////////////////////////////////////////////////
290

    
291
  private void solveObjectNow()
292
    {
293
    mSolveObject = false;
294
    blockEverything();
295
    doEffectNow( BaseEffect.Type.SOLVE );
296
    }
297

    
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

    
300
  private void initializeObjectNow()
301
    {
302
    mInitializeObject = false;
303
    mNewObject.initializeObject(mNextMoves);
304
    }
305

    
306
///////////////////////////////////////////////////////////////////////////////////////////////////
307

    
308
  private void setTextureMapNow()
309
    {
310
    mSetTextureMap = false;
311

    
312
    if( mNewObject!=null ) mNewObject.setTextureMap(mCubit,mFace,mNewColor);
313
    }
314

    
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316

    
317
  private void resetAllTextureMapsNow()
318
    {
319
    mResetAllTextureMaps = false;
320

    
321
    if( mNewObject!=null ) mNewObject.resetAllTextureMaps();
322
    }
323

    
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

    
326
  private void setQuatNow()
327
    {
328
    mSetQuat = false;
329
    mView.setQuat();
330
    }
331

    
332
///////////////////////////////////////////////////////////////////////////////////////////////////
333

    
334
  private void reportRecord()
335
    {
336
    RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
337
    RubikScores scores = RubikScores.getInstance();
338

    
339
    int object      = play.getObject();
340
    int size        = play.getSize();
341
    int level       = play.getLevel();
342
    ObjectList list = ObjectList.getObject(object);
343
    String name     = scores.getName();
344

    
345
    String record = list.name()+"_"+size+" level "+level+" time "+mNewRecord+" isNew: "+mIsNewRecord+" scrambleNum: "+mScrambleObjectNum;
346

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

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

    
369
///////////////////////////////////////////////////////////////////////////////////////////////////
370

    
371
  private void requestReview()
372
    {
373
    final RubikScores scores = RubikScores.getInstance();
374
    int numWins = scores.incrementNumWins();
375

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

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

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

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

    
422
///////////////////////////////////////////////////////////////////////////////////////////////////
423

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

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

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

    
446
///////////////////////////////////////////////////////////////////////////////////////////////////
447
//
448
///////////////////////////////////////////////////////////////////////////////////////////////////
449

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

    
455
///////////////////////////////////////////////////////////////////////////////////////////////////
456

    
457
  void setScreenSize(int width)
458
    {
459
    if( mNewObject!=null )
460
      {
461
      mNewObject.createTexture();
462
      mNewObject.recomputeScaleFactor(width);
463
      }
464

    
465
    mScreenWidth  = width;
466
    }
467

    
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469

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

    
478
///////////////////////////////////////////////////////////////////////////////////////////////////
479

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

    
485
///////////////////////////////////////////////////////////////////////////////////////////////////
486

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

    
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494

    
495
  void changeObject(ObjectList object, int size)
496
    {
497
    if( size>0 )
498
      {
499
      mChangeObject = true;
500
      mNextObject = object;
501
      mNextSize   = size;
502
      }
503
    }
504

    
505
///////////////////////////////////////////////////////////////////////////////////////////////////
506

    
507
  void setupObject(ObjectList object, int size, int[][] moves)
508
    {
509
    if( size>0 )
510
      {
511
      mSetupObject= true;
512
      mNextObject = object;
513
      mNextSize   = size;
514
      mNextMoves  = moves;
515
      }
516
    }
517

    
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519

    
520
  void setTextureMap(int cubit, int face, int newColor)
521
    {
522
    mSetTextureMap = true;
523

    
524
    mCubit    = cubit;
525
    mFace     = face;
526
    mNewColor = newColor;
527
    }
528

    
529
///////////////////////////////////////////////////////////////////////////////////////////////////
530

    
531
  boolean isTouchBlocked()
532
    {
533
    return mTouchBlocked;
534
    }
535

    
536
///////////////////////////////////////////////////////////////////////////////////////////////////
537

    
538
  public boolean isUINotBlocked()
539
    {
540
    return !mUIBlocked;
541
    }
542

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

    
545
  public void blockEverything()
546
    {
547
    mUIBlocked   = true;
548
    mTouchBlocked= true;
549
    }
550

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

    
553
  public void blockTouch()
554
    {
555
    mTouchBlocked= true;
556
    }
557

    
558
///////////////////////////////////////////////////////////////////////////////////////////////////
559

    
560
  public void unblockEverything()
561
    {
562
    mUIBlocked   = false;
563
    mTouchBlocked= false;
564
    }
565

    
566
///////////////////////////////////////////////////////////////////////////////////////////////////
567

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

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

    
575
  void setQuatOnNextRender()
576
    {
577
    mSetQuat = true;
578
    }
579

    
580
///////////////////////////////////////////////////////////////////////////////////////////////////
581

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

    
598
///////////////////////////////////////////////////////////////////////////////////////////////////
599
// PUBLIC API
600
///////////////////////////////////////////////////////////////////////////////////////////////////
601

    
602
  public void addRotation(MovesFinished listener, int axis, int rowBitmap, int angle, long duration)
603
    {
604
    mAddRotation = true;
605

    
606
    mAddActionListener    = listener;
607
    mAddRotationAxis      = axis;
608
    mAddRotationRowBitmap = rowBitmap;
609
    mAddRotationAngle     = angle;
610
    mAddRotationDuration  = duration;
611

    
612
    if( listener instanceof ScrambleEffect )
613
      {
614
      mDebug += (" (a "+axis+" "+rowBitmap+" "+angle+" "+(System.currentTimeMillis()-mDebugStartTime)+")");
615
      }
616
    }
617

    
618
///////////////////////////////////////////////////////////////////////////////////////////////////
619

    
620
  public void initializeObject(int[][] moves)
621
    {
622
    mInitializeObject = true;
623
    mNextMoves = moves;
624
    }
625

    
626
///////////////////////////////////////////////////////////////////////////////////////////////////
627

    
628
  public void scrambleObject(int num)
629
    {
630
    if( !mUIBlocked )
631
      {
632
      mScrambleObject = true;
633
      mScrambleObjectNum = num;
634
      mDebug = "";
635
      mDebugStartTime = System.currentTimeMillis();
636
      }
637
    }
638

    
639
///////////////////////////////////////////////////////////////////////////////////////////////////
640

    
641
  public void solveObject()
642
    {
643
    if( !mUIBlocked )
644
      {
645
      mSolveObject = true;
646
      }
647
    }
648

    
649
///////////////////////////////////////////////////////////////////////////////////////////////////
650

    
651
  public void resetAllTextureMaps()
652
    {
653
    mResetAllTextureMaps = true;
654
    }
655

    
656
///////////////////////////////////////////////////////////////////////////////////////////////////
657

    
658
  public TwistyObject getObject()
659
    {
660
    return mNewObject;
661
    }
662

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

    
665
  public TwistyObject getOldObject()
666
    {
667
    return mOldObject;
668
    }
669

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

    
672
  public int getNumScrambles()
673
    {
674
    return mScrambleObjectNum;
675
    }
676

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

    
679
  public void effectFinished(final long effectID)
680
    {
681
    if( effectID == mRotationFinishedID )
682
      {
683
      mRotationFinishedID = 0;
684
      removeRotation();
685
      }
686
    else if( effectID == mAddRotationID )
687
      {
688
      mAddRotationID = 0;
689
      mRemoveRotationID = effectID;
690
      removePatternRotation();
691
      }
692
    else
693
      {
694
      for(int i=0; i<BaseEffect.Type.LENGTH; i++)
695
        {
696
        if( effectID == mEffectID[i] )
697
          {
698
          if( i!=BaseEffect.Type.WIN.ordinal() )
699
            {
700
            unblockEverything();
701
            }
702

    
703
          if( i==BaseEffect.Type.SCRAMBLE.ordinal() )
704
            {
705
            final RubikActivity act = (RubikActivity)mView.getContext();
706

    
707
            act.runOnUiThread(new Runnable()
708
              {
709
              @Override
710
              public void run()
711
                {
712
                ScreenList.switchScreen( act, ScreenList.READ);
713
                }
714
              });
715
            }
716

    
717
          if( i==BaseEffect.Type.WIN.ordinal() )
718
            {
719
            if( ScreenList.getCurrentScreen()== ScreenList.SOLV )
720
              {
721
              final RubikActivity act = (RubikActivity)mView.getContext();
722
              Bundle bundle = new Bundle();
723
              bundle.putLong("time", mNewRecord );
724

    
725
              reportRecord();
726
              requestReview();
727

    
728
              if( mIsNewRecord )
729
                {
730
                RubikDialogNewRecord dialog = new RubikDialogNewRecord();
731
                dialog.setArguments(bundle);
732
                dialog.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
733
                }
734
              else
735
                {
736
                RubikDialogSolved dialog = new RubikDialogSolved();
737
                dialog.setArguments(bundle);
738
                dialog.show( act.getSupportFragmentManager(), RubikDialogSolved.getDialogTag() );
739
                }
740

    
741
              act.runOnUiThread(new Runnable()
742
                {
743
                @Override
744
                public void run()
745
                  {
746
                  ScreenList.switchScreen( act, ScreenList.DONE);
747
                  }
748
                });
749
              }
750
            }
751

    
752
          break;
753
          }
754
        }
755
      }
756
    }
757
  }
(2-2/4)