@sodyo/react-native-sodyo-sdk 3.18.8 → 5.0.0

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.
@@ -16,6 +16,7 @@ import javax.annotation.Nullable;
16
16
 
17
17
  import com.sodyo.sdk.SodyoScannerFragment;
18
18
 
19
+ @SuppressWarnings("deprecation")
19
20
  public class RNSodyoSdkView extends SimpleViewManager<FrameLayout> {
20
21
  static final String TAG = "RNSodyoSdkView";
21
22
 
@@ -44,25 +45,25 @@ public class RNSodyoSdkView extends SimpleViewManager<FrameLayout> {
44
45
 
45
46
  final FrameLayout view = new FrameLayout(context);
46
47
 
47
- // Obtain the current activity from the context
48
48
  Activity currentActivity = mCallerContext.getCurrentActivity();
49
49
  if (currentActivity == null) {
50
- // Handle the situation when the activity is null
51
50
  Log.e(TAG, "Current activity is null, cannot initialize SodyoScannerFragment");
52
- // Consider providing user feedback or a fallback mechanism
53
51
  return view;
54
52
  }
55
53
 
56
- // Proceed with initialization as the activity is not null
57
- if (sodyoFragment == null) {
58
- Log.i(TAG,"init SodyoScannerFragment");
59
- sodyoFragment = new SodyoScannerFragment();
54
+ FragmentManager fragmentManager = currentActivity.getFragmentManager();
55
+
56
+ // Clean up any previously added fragment to avoid "Fragment already added"
57
+ Fragment existing = fragmentManager.findFragmentByTag(TAG_FRAGMENT);
58
+ if (existing != null) {
59
+ Log.w(TAG, "Removing existing SodyoScannerFragment before re-adding");
60
+ fragmentManager.beginTransaction().remove(existing).commitNowAllowingStateLoss();
60
61
  }
61
62
 
62
- // Use the current activity's fragment manager
63
- FragmentManager fragmentManager = currentActivity.getFragmentManager();
64
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
63
+ Log.i(TAG,"init SodyoScannerFragment");
64
+ sodyoFragment = new SodyoScannerFragment();
65
65
 
66
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
66
67
  fragmentTransaction.add(sodyoFragment, TAG_FRAGMENT).commitAllowingStateLoss();
67
68
  fragmentManager.executePendingTransactions();
68
69
 
@@ -84,7 +85,7 @@ public class RNSodyoSdkView extends SimpleViewManager<FrameLayout> {
84
85
  Fragment fragment = fragmentManager.findFragmentByTag(TAG_FRAGMENT);
85
86
 
86
87
  if (fragment != null) {
87
- fragmentManager.beginTransaction().remove(fragment).commit();
88
+ fragmentManager.beginTransaction().remove(fragment).commitNowAllowingStateLoss();
88
89
  }
89
90
  } catch (Exception e) {
90
91
  e.printStackTrace();
@@ -13,7 +13,7 @@
13
13
  #endif
14
14
 
15
15
  #import <UIKit/UIKit.h>
16
- #import "RNSodyoSdkView.m"
16
+ #import "RNSodyoSdkView.h"
17
17
  #import "RNSodyoScanner.h"
18
18
 
19
19
  @interface RNSodyoSdkManager : RCTViewManager {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sodyo/react-native-sodyo-sdk",
3
- "version": "3.18.8",
3
+ "version": "5.0.0",
4
4
  "description": "RNSodyoSdk",
5
5
  "main": "sodyosdk.js",
6
6
  "typings": "./sodyosdk.d.ts",