Project

General

Profile

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

magiccube / src / main / java / org / distorted / tutorials / TutorialObjectLibInterface.java @ 2cf21fdc

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
import org.distorted.objectlib.BuildConfig;
16
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 e019c70b Leszek Koltunski
   WeakReference<TutorialActivity> mAct;
26
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28
29
  TutorialObjectLibInterface(TutorialActivity act)
30
    {
31
    mAct = new WeakReference<>(act);
32
    }
33
34 1fa125c2 Leszek Koltunski
  public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
35 95472aca Leszek Koltunski
  public void onScrambleEffectFinished() { }
36
  public void onBeginRotation() { }
37
  public void onSolved() { }
38
  public void onObjectCreated(long time) { }
39 5c4ed8ed Leszek Koltunski
  public void onReplaceModeDown(int cubit, int face) { }
40
  public void onReplaceModeUp() { }
41 c020555e Leszek Koltunski
  public void reportJSONError(String error, int ordinal) { }
42 95472aca Leszek Koltunski
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44
45 eb647d5e Leszek Koltunski
  public void reportProblem(String problem, boolean reportException)
46 95472aca Leszek Koltunski
    {
47
    if( BuildConfig.DEBUG )
48
      {
49
      android.util.Log.e("interface", problem);
50
      }
51
    else
52
      {
53 eb647d5e Leszek Koltunski
      if( reportException )
54
        {
55
        Exception ex = new Exception(problem);
56
        FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
57
        crashlytics.setCustomKey("problem" , problem);
58
        crashlytics.recordException(ex);
59
        }
60
      else
61
        {
62
        FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
63
        crashlytics.log(problem);
64
        }
65 95472aca Leszek Koltunski
      }
66
    }
67
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69
70
  private void reportUIProblem(int place, long pause, long resume, long time)
71
    {
72
    String error = "UI BLOCK "+place+" blocked for "+time;
73
74
    if( BuildConfig.DEBUG )
75
       {
76
       android.util.Log.e("D", error);
77
       }
78
    else
79
      {
80
      Exception ex = new Exception(error);
81
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
82
      crashlytics.setCustomKey("pause" , pause );
83
      crashlytics.setCustomKey("resume", resume );
84
      crashlytics.recordException(ex);
85
      }
86
    }
87
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
90
  private void reportTouchProblem(int place, long pause, long resume, long time)
91
    {
92
    String error = "TOUCH BLOCK "+place+" blocked for "+time;
93
94
    if( BuildConfig.DEBUG )
95
       {
96
       android.util.Log.e("D", error);
97
       }
98
    else
99
      {
100
      Exception ex = new Exception(error);
101
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
102
      crashlytics.setCustomKey("pause" , pause );
103
      crashlytics.setCustomKey("resume", resume);
104
      crashlytics.recordException(ex);
105
      }
106
    }
107
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109
110
  private void reportThreadProblem(int place, long pause, long resume, long time)
111
    {
112
    String error = EffectMessageSender.reportState();
113
114
    if( BuildConfig.DEBUG )
115
       {
116
       android.util.Log.e("D", error);
117
       }
118
    else
119
      {
120
      Exception ex = new Exception(error);
121
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
122
      crashlytics.setCustomKey("pause" , pause  );
123
      crashlytics.setCustomKey("resume", resume );
124
      crashlytics.recordException(ex);
125
      }
126
    }
127
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129
130
  public void reportBlockProblem(int type, int place, long pause, long resume, long time)
131
    {
132
    switch(type)
133
      {
134
      case BlockController.TYPE_UI    : reportUIProblem(place,pause,resume,time); break;
135
      case BlockController.TYPE_TOUCH : reportTouchProblem(place,pause,resume,time); break;
136
      case BlockController.TYPE_THREAD: reportThreadProblem(place,pause,resume,time); break;
137
      }
138
    }
139 dd1a65c1 Leszek Koltunski
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
142 e019c70b Leszek Koltunski
   public void onFinishRotation(int axis, int row, int angle)
143 dd1a65c1 Leszek Koltunski
     {
144 e019c70b Leszek Koltunski
     TutorialActivity act = mAct.get();
145
     TutorialScreen state = act.getState();
146 4cad53b4 Leszek Koltunski
     if( state!=null ) state.addMove(act, axis, row, angle);
147 dd1a65c1 Leszek Koltunski
     }
148
149
///////////////////////////////////////////////////////////////////////////////////////////////////
150
151 e019c70b Leszek Koltunski
   public void failedToDrag()
152 dd1a65c1 Leszek Koltunski
     {
153 e019c70b Leszek Koltunski
     TutorialActivity act = mAct.get();
154
     TutorialScreen state = act.getState();
155 dd1a65c1 Leszek Koltunski
     state.reddenLock(act);
156
     }
157 1cd323dd Leszek Koltunski
}