Project

General

Profile

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

magiccube / src / main / java / org / distorted / tutorials / TutorialObjectLibInterface.java @ 4c6cbfa2

1 1cd323dd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2 05c20dad Leszek Koltunski
// Copyright 2021 Leszek Koltunski                                                               //
3 1cd323dd Leszek Koltunski
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 bb62ca3f Leszek Koltunski
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8 1cd323dd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
package org.distorted.tutorials;
11
12 95472aca Leszek Koltunski
import com.google.firebase.crashlytics.FirebaseCrashlytics;
13
14
import org.distorted.library.message.EffectMessageSender;
15 847f5370 leszek
import org.distorted.main.BuildConfig;
16 95472aca Leszek Koltunski
import org.distorted.objectlib.helpers.BlockController;
17 e019c70b Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectLibInterface;
18 1cd323dd Leszek Koltunski
19 e019c70b Leszek Koltunski
import java.lang.ref.WeakReference;
20
21 1cd323dd Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
22
23 e019c70b Leszek Koltunski
public class TutorialObjectLibInterface implements ObjectLibInterface
24 1cd323dd Leszek Koltunski
{
25 ce31f774 Leszek Koltunski
  private final WeakReference<TutorialActivity> mAct;
26 e019c70b Leszek Koltunski
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28
29
  TutorialObjectLibInterface(TutorialActivity act)
30
    {
31
    mAct = new WeakReference<>(act);
32
    }
33
34 ce31f774 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
35
36 1fa125c2 Leszek Koltunski
  public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
37 95472aca Leszek Koltunski
  public void onScrambleEffectFinished() { }
38
  public void onBeginRotation() { }
39
  public void onSolved() { }
40
  public void onObjectCreated(long time) { }
41 5c4ed8ed Leszek Koltunski
  public void onReplaceModeDown(int cubit, int face) { }
42
  public void onReplaceModeUp() { }
43 c020555e Leszek Koltunski
  public void reportJSONError(String error, int ordinal) { }
44 95472aca Leszek Koltunski
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46
47 eb647d5e Leszek Koltunski
  public void reportProblem(String problem, boolean reportException)
48 95472aca Leszek Koltunski
    {
49
    if( BuildConfig.DEBUG )
50
      {
51
      android.util.Log.e("interface", problem);
52
      }
53
    else
54
      {
55 eb647d5e Leszek Koltunski
      if( reportException )
56
        {
57
        Exception ex = new Exception(problem);
58
        FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
59
        crashlytics.setCustomKey("problem" , problem);
60
        crashlytics.recordException(ex);
61
        }
62
      else
63
        {
64
        FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
65
        crashlytics.log(problem);
66
        }
67 95472aca Leszek Koltunski
      }
68
    }
69
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71
72 919b830e Leszek Koltunski
  private void reportScramblingProblem(int place, long pause, long resume, long time)
73 95472aca Leszek Koltunski
    {
74 919b830e Leszek Koltunski
    String error = "SCRAMBLING BLOCK "+place+" blocked for "+time;
75 95472aca Leszek Koltunski
76
    if( BuildConfig.DEBUG )
77
       {
78
       android.util.Log.e("D", error);
79
       }
80
    else
81
      {
82
      Exception ex = new Exception(error);
83
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
84
      crashlytics.setCustomKey("pause" , pause );
85
      crashlytics.setCustomKey("resume", resume );
86
      crashlytics.recordException(ex);
87
      }
88
    }
89
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91
92 919b830e Leszek Koltunski
  private void reportRotationProblem(int place, long pause, long resume, long time)
93 95472aca Leszek Koltunski
    {
94 919b830e Leszek Koltunski
    String error = "ROTATION BLOCK "+place+" blocked for "+time;
95 95472aca Leszek Koltunski
96
    if( BuildConfig.DEBUG )
97
       {
98
       android.util.Log.e("D", error);
99
       }
100
    else
101
      {
102
      Exception ex = new Exception(error);
103
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
104
      crashlytics.setCustomKey("pause" , pause );
105
      crashlytics.setCustomKey("resume", resume);
106
      crashlytics.recordException(ex);
107
      }
108
    }
109
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111
112
  private void reportThreadProblem(int place, long pause, long resume, long time)
113
    {
114
    String error = EffectMessageSender.reportState();
115
116
    if( BuildConfig.DEBUG )
117
       {
118
       android.util.Log.e("D", error);
119
       }
120
    else
121
      {
122
      Exception ex = new Exception(error);
123
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
124
      crashlytics.setCustomKey("pause" , pause  );
125
      crashlytics.setCustomKey("resume", resume );
126
      crashlytics.recordException(ex);
127
      }
128
    }
129
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131
132
  public void reportBlockProblem(int type, int place, long pause, long resume, long time)
133
    {
134
    switch(type)
135
      {
136 919b830e Leszek Koltunski
      case BlockController.TYPE_SCRAMBLING: reportScramblingProblem(place,pause,resume,time); break;
137
      case BlockController.TYPE_ROTATION  : reportRotationProblem(place,pause,resume,time); break;
138
      case BlockController.TYPE_THREAD    : reportThreadProblem(place,pause,resume,time); break;
139 95472aca Leszek Koltunski
      }
140
    }
141 dd1a65c1 Leszek Koltunski
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143
144 4c6cbfa2 leszek
  public void onRemoveRotation(int axis, int row, int angle)
145 dd1a65c1 Leszek Koltunski
     {
146 e019c70b Leszek Koltunski
     TutorialActivity act = mAct.get();
147
     TutorialScreen state = act.getState();
148 4cad53b4 Leszek Koltunski
     if( state!=null ) state.addMove(act, axis, row, angle);
149 dd1a65c1 Leszek Koltunski
     }
150
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152
153 ce31f774 Leszek Koltunski
  public void failedToDrag()
154 dd1a65c1 Leszek Koltunski
     {
155 e019c70b Leszek Koltunski
     TutorialActivity act = mAct.get();
156
     TutorialScreen state = act.getState();
157 dd1a65c1 Leszek Koltunski
     state.reddenLock(act);
158
     }
159 1cd323dd Leszek Koltunski
}