Project

General

Profile

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

magiccube / src / main / java / org / distorted / tutorials / TutorialObjectLibInterface.java @ 8723caee

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