Project

General

Profile

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

magiccube / src / main / java / org / distorted / config / ConfigObjectLibInterface.java @ c020555e

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.config;
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

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
public class ConfigObjectLibInterface implements ObjectLibInterface
32
{
33
  public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
34
  public void onScrambleEffectFinished() { }
35
  public void onBeginRotation() { }
36
  public void onSolved() { }
37
  public void onObjectCreated(long time) { }
38
  public void onReplaceModeDown(int cubit, int face) { }
39
  public void onReplaceModeUp() { }
40
  public void onFinishRotation(int axis, int row, int angle) { }
41
  public void failedToDrag() { }
42
  public void reportJSONError(String error, int ordinal) { }
43

    
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

    
46
  public void reportProblem(String problem, boolean reportException)
47
    {
48
    if( BuildConfig.DEBUG )
49
      {
50
      android.util.Log.e("interface", problem);
51
      }
52
    else
53
      {
54
      if( reportException )
55
        {
56
        Exception ex = new Exception(problem);
57
        FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
58
        crashlytics.setCustomKey("problem" , problem);
59
        crashlytics.recordException(ex);
60
        }
61
      else
62
        {
63
        FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
64
        crashlytics.log(problem);
65
        }
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
}
(2-2/6)