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/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