Project

General

Profile

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

magiccube / src / main / java / org / distorted / tutorials / TutorialObjectLibInterface.java @ 95472aca

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 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.tutorials;
21

    
22
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
import org.distorted.objectlib.helpers.ObjectLibInterface;
28
import org.distorted.objectlib.main.ObjectType;
29

    
30
import java.lang.ref.WeakReference;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
public class TutorialObjectLibInterface implements ObjectLibInterface
35
{
36
   WeakReference<TutorialActivity> mAct;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
  TutorialObjectLibInterface(TutorialActivity act)
41
    {
42
    mAct = new WeakReference<>(act);
43
    }
44

    
45
  public void onWinEffectFinished(String debug, int scrambleNum) { }
46
  public void onScrambleEffectFinished() { }
47
  public void onBeginRotation() { }
48
  public void onSolved() { }
49
  public void onObjectCreated(long time) { }
50
  public int getCurrentColor() { return 0; }
51
  public int cubitIsLocked(ObjectType type, int cubit) { return 0; }
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  public void reportProblem(String problem)
56
    {
57
    if( BuildConfig.DEBUG )
58
      {
59
      android.util.Log.e("interface", problem);
60
      }
61
    else
62
      {
63
      Exception ex = new Exception(problem);
64
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
65
      crashlytics.setCustomKey("problem" , problem);
66
      crashlytics.recordException(ex);
67
      }
68
    }
69

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

    
72
  private void reportUIProblem(int place, long pause, long resume, long time)
73
    {
74
    String error = "UI BLOCK "+place+" blocked for "+time;
75

    
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
  private void reportTouchProblem(int place, long pause, long resume, long time)
93
    {
94
    String error = "TOUCH BLOCK "+place+" blocked for "+time;
95

    
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
      case BlockController.TYPE_UI    : reportUIProblem(place,pause,resume,time); break;
137
      case BlockController.TYPE_TOUCH : reportTouchProblem(place,pause,resume,time); break;
138
      case BlockController.TYPE_THREAD: reportThreadProblem(place,pause,resume,time); break;
139
      }
140
    }
141

    
142
///////////////////////////////////////////////////////////////////////////////////////////////////
143

    
144
   public void onFinishRotation(int axis, int row, int angle)
145
     {
146
     TutorialActivity act = mAct.get();
147
     TutorialScreen state = act.getState();
148
     state.addMove(act, axis, row, angle);
149
     }
150

    
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152

    
153
   public void failedToDrag()
154
     {
155
     TutorialActivity act = mAct.get();
156
     TutorialScreen state = act.getState();
157
     state.reddenLock(act);
158
     }
159
}
(3-3/7)