react-native-stallion 2.0.0-alpha.2 → 2.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,6 @@ import com.stallion.storage.StallionConfigConstants;
17
17
 
18
18
  import com.stallion.storage.StallionMetaConstants;
19
19
  import com.stallion.storage.StallionStateManager;
20
- import com.stallion.utils.StallionExceptionHandler;
21
20
 
22
21
  import org.json.JSONArray;
23
22
  import org.json.JSONException;
@@ -36,7 +35,6 @@ public class StallionModule extends ReactContextBaseJavaModule implements Lifecy
36
35
  StallionStateManager.init(reactContext);
37
36
  this.stallionStateManager = StallionStateManager.getInstance();
38
37
  this.currentReactContext = reactContext;
39
- StallionExceptionHandler.initErrorBoundary(reactContext);
40
38
  reactContext.addLifecycleEventListener(this);
41
39
  }
42
40
 
@@ -3,6 +3,8 @@ package com.stallion.storage;
3
3
  import android.content.Context;
4
4
  import android.content.SharedPreferences;
5
5
 
6
+ import com.stallion.utils.StallionExceptionHandler;
7
+
6
8
  import org.json.JSONException;
7
9
  import org.json.JSONObject;
8
10
 
@@ -32,6 +34,7 @@ public class StallionStateManager {
32
34
  public static synchronized void init(Context context) {
33
35
  if (instance == null) {
34
36
  instance = new StallionStateManager(context);
37
+ StallionExceptionHandler.initErrorBoundary();
35
38
  }
36
39
  }
37
40
 
@@ -88,7 +91,7 @@ public class StallionStateManager {
88
91
  public void setString(String key, String value) {
89
92
  SharedPreferences.Editor editor = sharedPreferences.edit();
90
93
  editor.putString(key, value);
91
- editor.apply();
94
+ editor.commit();
92
95
  }
93
96
 
94
97
  public StallionConfig getStallionConfig() {
@@ -1,10 +1,7 @@
1
1
  package com.stallion.utils;
2
2
 
3
- import android.app.Activity;
4
- import android.content.Intent;
5
3
  import android.util.Log;
6
4
 
7
- import com.facebook.react.bridge.ReactApplicationContext;
8
5
  import com.stallion.events.StallionEventConstants;
9
6
  import com.stallion.events.StallionEventManager;
10
7
  import com.stallion.storage.StallionMetaConstants;
@@ -17,11 +14,15 @@ public class StallionExceptionHandler {
17
14
  private static Thread.UncaughtExceptionHandler _androidUncaughtExceptionHandler;
18
15
  private static Thread _exceptionThread;
19
16
  private static Throwable _exceptionThrowable;
20
- private static Activity _reactActivity;
17
+ private static boolean isErrorBoundaryInitialized = false;
18
+
19
+ public static void initErrorBoundary() {
20
+ if (isErrorBoundaryInitialized) {
21
+ return; // Prevent multiple initializations
22
+ }
23
+ isErrorBoundaryInitialized = true;
21
24
 
22
- public static void initErrorBoundary(ReactApplicationContext currentContext) {
23
25
  _androidUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
24
- _reactActivity = currentContext.getCurrentActivity();
25
26
  Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
26
27
  _exceptionThread = thread;
27
28
  _exceptionThrowable = throwable;
@@ -84,14 +85,7 @@ public class StallionExceptionHandler {
84
85
 
85
86
  StallionSlotManager.rollbackStage();
86
87
 
87
- if (_reactActivity != null) {
88
- Intent errorIntent = new Intent(_reactActivity, StallionErrorActivity.class);
89
- errorIntent.putExtra("stack_trace_string", stackTraceString);
90
- _reactActivity.startActivity(errorIntent);
91
- _reactActivity.finish();
92
- } else {
93
- continueExceptionFlow();
94
- }
88
+ continueExceptionFlow();
95
89
  }
96
90
 
97
91
  public static void continueExceptionFlow() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-stallion",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.3",
4
4
  "description": "Offical React Native SDK for Stallion",
5
5
  "main": "index",
6
6
  "types": "types/index.d.ts",