@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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
63
|
-
|
|
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).
|
|
88
|
+
fragmentManager.beginTransaction().remove(fragment).commitNowAllowingStateLoss();
|
|
88
89
|
}
|
|
89
90
|
} catch (Exception e) {
|
|
90
91
|
e.printStackTrace();
|
package/ios/RNSodyoSdkManager.m
CHANGED