Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedPlayLibInterface.java @ 39176a1f

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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.bandaged;
21

    
22
import java.lang.ref.WeakReference;
23

    
24
import com.google.firebase.crashlytics.FirebaseCrashlytics;
25

    
26
import org.distorted.library.message.EffectMessageSender;
27
import org.distorted.objectlib.BuildConfig;
28
import org.distorted.objectlib.helpers.BlockController;
29
import org.distorted.objectlib.helpers.ObjectLibInterface;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
public class BandagedPlayLibInterface implements ObjectLibInterface
34
{
35
  private final WeakReference<BandagedPlayActivity> mAct;
36

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

    
39
  BandagedPlayLibInterface(BandagedPlayActivity act)
40
    {
41
    mAct = new WeakReference<>(act);
42
    }
43

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

    
46
  public void onWinEffectFinished(long startTime, long endTime, String debug, int scrambleNum) { }
47
  public void onScrambleEffectFinished() { }
48
  public void onBeginRotation() { }
49
  public void onSolved() { }
50
  public void onObjectCreated(long time) { }
51
  public void onReplaceModeDown(int cubit, int face) { }
52
  public void onReplaceModeUp() { }
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

    
56
  public void onFinishRotation(int axis, int row, int angle)
57
    {
58
    BandagedPlayActivity act = mAct.get();
59

    
60
    if( act!=null )
61
      {
62
      BandagedPlayScreen play = act.getScreen();
63
      play.addMove(act,axis,row,angle);
64
      }
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  public void failedToDrag()
70
    {
71
    BandagedPlayActivity act = mAct.get();
72

    
73
    if( act!=null )
74
      {
75
      BandagedPlayScreen play = act.getScreen();
76
      play.reddenLock(act);
77
      }
78
    }
79

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

    
82
  public void reportProblem(String problem, boolean reportException)
83
    {
84
    if( BuildConfig.DEBUG )
85
      {
86
      android.util.Log.e("interface", problem);
87
      }
88
    else
89
      {
90
      if( reportException )
91
        {
92
        Exception ex = new Exception(problem);
93
        FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
94
        crashlytics.setCustomKey("problem" , problem);
95
        crashlytics.recordException(ex);
96
        }
97
      else
98
        {
99
        FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
100
        crashlytics.log(problem);
101
        }
102
      }
103
    }
104

    
105
///////////////////////////////////////////////////////////////////////////////////////////////////
106

    
107
  private void reportUIProblem(int place, long pause, long resume, long time)
108
    {
109
    String error = "UI BLOCK "+place+" blocked for "+time;
110

    
111
    if( BuildConfig.DEBUG )
112
       {
113
       android.util.Log.e("D", error);
114
       }
115
    else
116
      {
117
      Exception ex = new Exception(error);
118
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
119
      crashlytics.setCustomKey("pause" , pause );
120
      crashlytics.setCustomKey("resume", resume );
121
      crashlytics.recordException(ex);
122
      }
123
    }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

    
127
  private void reportTouchProblem(int place, long pause, long resume, long time)
128
    {
129
    String error = "TOUCH BLOCK "+place+" blocked for "+time;
130

    
131
    if( BuildConfig.DEBUG )
132
       {
133
       android.util.Log.e("D", error);
134
       }
135
    else
136
      {
137
      Exception ex = new Exception(error);
138
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
139
      crashlytics.setCustomKey("pause" , pause );
140
      crashlytics.setCustomKey("resume", resume);
141
      crashlytics.recordException(ex);
142
      }
143
    }
144

    
145
///////////////////////////////////////////////////////////////////////////////////////////////////
146

    
147
  private void reportThreadProblem(int place, long pause, long resume, long time)
148
    {
149
    String error = EffectMessageSender.reportState();
150

    
151
    if( BuildConfig.DEBUG )
152
       {
153
       android.util.Log.e("D", error);
154
       }
155
    else
156
      {
157
      Exception ex = new Exception(error);
158
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
159
      crashlytics.setCustomKey("pause" , pause  );
160
      crashlytics.setCustomKey("resume", resume );
161
      crashlytics.recordException(ex);
162
      }
163
    }
164

    
165
///////////////////////////////////////////////////////////////////////////////////////////////////
166

    
167
  public void reportBlockProblem(int type, int place, long pause, long resume, long time)
168
    {
169
    switch(type)
170
      {
171
      case BlockController.TYPE_UI    : reportUIProblem(place,pause,resume,time); break;
172
      case BlockController.TYPE_TOUCH : reportTouchProblem(place,pause,resume,time); break;
173
      case BlockController.TYPE_THREAD: reportThreadProblem(place,pause,resume,time); break;
174
      }
175
    }
176
}
(10-10/13)