@sodyo/react-native-sodyo-sdk 3.9.14 → 3.10.1
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.
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
[SodyoSDK for iOS](https://github.com/sodyo-ltd/SodyoSDKPod) v3.61.01
|
|
5
5
|
|
|
6
|
-
[SodyoSDK for Android](https://search.maven.org/search?q=a:sodyo-android-sdk) 3.62.
|
|
6
|
+
[SodyoSDK for Android](https://search.maven.org/search?q=a:sodyo-android-sdk) 3.62.14
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
## Install
|
package/android/build.gradle
CHANGED
|
@@ -55,7 +55,7 @@ repositories {
|
|
|
55
55
|
|
|
56
56
|
dependencies {
|
|
57
57
|
implementation ('com.facebook.react:react-native:+')
|
|
58
|
-
implementation ('com.sodyo:sodyo-android-sdk:3.62.
|
|
58
|
+
implementation ('com.sodyo:sodyo-android-sdk:3.62.14') {
|
|
59
59
|
transitive = true
|
|
60
60
|
exclude group: 'com.parse.bolts', module: 'bolts-android'
|
|
61
61
|
}
|
|
@@ -11,6 +11,8 @@ import android.widget.FrameLayout;
|
|
|
11
11
|
import android.app.Fragment;
|
|
12
12
|
import android.app.FragmentManager;
|
|
13
13
|
import android.app.FragmentTransaction;
|
|
14
|
+
import android.app.Activity;
|
|
15
|
+
|
|
14
16
|
import javax.annotation.Nullable;
|
|
15
17
|
|
|
16
18
|
import com.sodyo.sdk.SodyoScannerFragment;
|
|
@@ -43,16 +45,26 @@ public class RNSodyoSdkView extends SimpleViewManager<FrameLayout> {
|
|
|
43
45
|
|
|
44
46
|
final FrameLayout view = new FrameLayout(context);
|
|
45
47
|
|
|
48
|
+
// Obtain the current activity from the context
|
|
49
|
+
Activity currentActivity = mCallerContext.getCurrentActivity();
|
|
50
|
+
if (currentActivity == null) {
|
|
51
|
+
// Handle the situation when the activity is null
|
|
52
|
+
Log.e(TAG, "Current activity is null, cannot initialize SodyoScannerFragment");
|
|
53
|
+
// Consider providing user feedback or a fallback mechanism
|
|
54
|
+
return view;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Proceed with initialization as the activity is not null
|
|
46
58
|
if (sodyoFragment == null) {
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
Log.i(TAG,"init SodyoScannerFragment");
|
|
60
|
+
sodyoFragment = new SodyoScannerFragment();
|
|
49
61
|
}
|
|
50
62
|
|
|
51
|
-
|
|
63
|
+
// Use the current activity's fragment manager
|
|
64
|
+
FragmentManager fragmentManager = currentActivity.getFragmentManager();
|
|
52
65
|
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
|
53
66
|
|
|
54
|
-
fragmentTransaction.add(sodyoFragment, TAG_FRAGMENT).
|
|
55
|
-
|
|
67
|
+
fragmentTransaction.add(sodyoFragment, TAG_FRAGMENT).commitAllowingStateLoss();
|
|
56
68
|
fragmentManager.executePendingTransactions();
|
|
57
69
|
|
|
58
70
|
view.addView(sodyoFragment.getView(), FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|