Project

General

Profile

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

magiccube / src / main / java / org / distorted / config / ConfigObjectLibInterface.java @ 1fa125c2

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

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

    
45
  public void reportProblem(String problem, boolean reportException)
46
    {
47
    if( BuildConfig.DEBUG )
48
      {
49
      android.util.Log.e("interface", problem);
50
      }
51
    else
52
      {
53
      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
      }
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
}
(2-2/6)