Project

General

Profile

« Previous | Next » 

Revision 95472aca

Added by Leszek Koltunski over 2 years ago

Remove dependancies on Firebase from objectlib.
Report such errors to the application via the Interface.

View differences:

src/main/java/org/distorted/main/RubikObjectLibInterface.java
30 30
import com.google.android.play.core.tasks.OnFailureListener;
31 31
import com.google.android.play.core.tasks.Task;
32 32
import com.google.firebase.analytics.FirebaseAnalytics;
33
import com.google.firebase.crashlytics.FirebaseCrashlytics;
33 34

  
35
import org.distorted.library.message.EffectMessageSender;
36
import org.distorted.objectlib.BuildConfig;
37
import org.distorted.objectlib.helpers.BlockController;
34 38
import org.distorted.objectlib.helpers.ObjectLibInterface;
35 39
import org.distorted.objectlib.main.ObjectType;
36 40

  
......
314 318

  
315 319
    }
316 320

  
321
///////////////////////////////////////////////////////////////////////////////////////////////////
322

  
323
  public void reportProblem(String problem)
324
    {
325
    if( BuildConfig.DEBUG )
326
      {
327
      android.util.Log.e("interface", problem);
328
      }
329
    else
330
      {
331
      Exception ex = new Exception(problem);
332
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
333
      crashlytics.setCustomKey("problem" , problem);
334
      crashlytics.recordException(ex);
335
      }
336
    }
337

  
338
///////////////////////////////////////////////////////////////////////////////////////////////////
339

  
340
  private void reportUIProblem(int place, long pause, long resume, long time)
341
    {
342
    String error = "UI BLOCK "+place+" blocked for "+time;
343

  
344
    if( BuildConfig.DEBUG )
345
       {
346
       android.util.Log.e("D", error);
347
       }
348
    else
349
      {
350
      Exception ex = new Exception(error);
351
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
352
      crashlytics.setCustomKey("pause" , pause );
353
      crashlytics.setCustomKey("resume", resume );
354
      crashlytics.recordException(ex);
355
      }
356
    }
357

  
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359

  
360
  private void reportTouchProblem(int place, long pause, long resume, long time)
361
    {
362
    String error = "TOUCH BLOCK "+place+" blocked for "+time;
363

  
364
    if( BuildConfig.DEBUG )
365
       {
366
       android.util.Log.e("D", error);
367
       }
368
    else
369
      {
370
      Exception ex = new Exception(error);
371
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
372
      crashlytics.setCustomKey("pause" , pause );
373
      crashlytics.setCustomKey("resume", resume);
374
      crashlytics.recordException(ex);
375
      }
376
    }
377

  
378
///////////////////////////////////////////////////////////////////////////////////////////////////
379

  
380
  private void reportThreadProblem(int place, long pause, long resume, long time)
381
    {
382
    String error = EffectMessageSender.reportState();
383

  
384
    if( BuildConfig.DEBUG )
385
       {
386
       android.util.Log.e("D", error);
387
       }
388
    else
389
      {
390
      Exception ex = new Exception(error);
391
      FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance();
392
      crashlytics.setCustomKey("pause" , pause  );
393
      crashlytics.setCustomKey("resume", resume );
394
      crashlytics.recordException(ex);
395
      }
396
    }
397

  
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399

  
400
  public void reportBlockProblem(int type, int place, long pause, long resume, long time)
401
    {
402
    switch(type)
403
      {
404
      case BlockController.TYPE_UI    : reportUIProblem(place,pause,resume,time); break;
405
      case BlockController.TYPE_TOUCH : reportTouchProblem(place,pause,resume,time); break;
406
      case BlockController.TYPE_THREAD: reportThreadProblem(place,pause,resume,time); break;
407
      }
408
    }
409

  
317 410
///////////////////////////////////////////////////////////////////////////////////////////////////
318 411

  
319 412
  public int getCurrentColor()
src/main/java/org/distorted/tutorials/TutorialObjectLibInterface.java
19 19

  
20 20
package org.distorted.tutorials;
21 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;
22 27
import org.distorted.objectlib.helpers.ObjectLibInterface;
23 28
import org.distorted.objectlib.main.ObjectType;
24 29

  
......
37 42
    mAct = new WeakReference<>(act);
38 43
    }
39 44

  
40
   public void onWinEffectFinished(String debug, int scrambleNum) { }
41
   public void onScrambleEffectFinished() { }
42
   public void onBeginRotation() { }
43
   public void onSolved() { }
44
   public void onObjectCreated(long time) { }
45
   public int getCurrentColor() { return 0; }
46
   public int cubitIsLocked(ObjectType type, int cubit) { return 0; }
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
    }
47 141

  
48 142
///////////////////////////////////////////////////////////////////////////////////////////////////
49 143

  

Also available in: Unified diff