react-native-firework-sdk 1.1.1 → 1.1.2
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.
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
android:name="com.fireworksdk.bridge.reactnative.pages.FWVideoShoppingCartActivity"
|
|
12
12
|
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
|
|
13
13
|
/>
|
|
14
|
+
<provider
|
|
15
|
+
android:authorities="com.fireworksdk.bridge.reactnative"
|
|
16
|
+
android:name=".reactnative.FWInitializationProvider"
|
|
17
|
+
android:exported="false"
|
|
18
|
+
/>
|
|
14
19
|
<meta-data
|
|
15
20
|
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
|
|
16
21
|
android:value="true" />
|
|
@@ -19,4 +24,5 @@
|
|
|
19
24
|
android:value="true" />
|
|
20
25
|
</application>
|
|
21
26
|
|
|
27
|
+
|
|
22
28
|
</manifest>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
package com.fireworksdk.bridge.reactnative
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.app.Application
|
|
5
|
+
import android.content.ContentProvider
|
|
6
|
+
import android.content.ContentValues
|
|
7
|
+
import android.database.Cursor
|
|
8
|
+
import android.net.Uri
|
|
9
|
+
import android.os.Bundle
|
|
10
|
+
import com.fireworksdk.bridge.models.weakProperty
|
|
11
|
+
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
12
|
+
|
|
13
|
+
class FWInitializationProvider: ContentProvider() {
|
|
14
|
+
|
|
15
|
+
var application: Application? = null
|
|
16
|
+
var resumedActivity by weakProperty<Activity?>()
|
|
17
|
+
|
|
18
|
+
override fun onCreate(): Boolean {
|
|
19
|
+
sInstance = this
|
|
20
|
+
val context = context
|
|
21
|
+
if (context != null) {
|
|
22
|
+
// Many Initializer's expect the `applicationContext` to be non-null. This
|
|
23
|
+
// typically happens when `android:sharedUid` is used. In such cases, we postpone
|
|
24
|
+
// initialization altogether, and rely on lazy init.
|
|
25
|
+
// More context: b/196959015
|
|
26
|
+
val applicationContext = context.applicationContext as Application?
|
|
27
|
+
application = applicationContext
|
|
28
|
+
|
|
29
|
+
if (applicationContext != null) {
|
|
30
|
+
applicationContext.registerActivityLifecycleCallbacks(object : Application.ActivityLifecycleCallbacks {
|
|
31
|
+
override fun onActivityCreated(activity: Activity, bundle: Bundle?) {
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun onActivityStarted(activity: Activity) {
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun onActivityResumed(activity: Activity) {
|
|
38
|
+
resumedActivity = activity
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override fun onActivityPaused(activity: Activity) {
|
|
42
|
+
if (resumedActivity == activity) {
|
|
43
|
+
resumedActivity = null
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override fun onActivityStopped(activity: Activity) {
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun onActivitySaveInstanceState(activity: Activity, bundle: Bundle) {
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
override fun onActivityDestroyed(activity: Activity) {
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
} else {
|
|
59
|
+
FWLogUtils.w {"Deferring initialization because `applicationContext` is null."}
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
throw Exception("Context cannot be null")
|
|
63
|
+
}
|
|
64
|
+
return true
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
override fun query(
|
|
68
|
+
p0: Uri,
|
|
69
|
+
p1: Array<out String>?,
|
|
70
|
+
p2: String?,
|
|
71
|
+
p3: Array<out String>?,
|
|
72
|
+
p4: String?
|
|
73
|
+
): Cursor? {
|
|
74
|
+
throw IllegalStateException("Not allowed.")
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override fun getType(p0: Uri): String? {
|
|
78
|
+
throw IllegalStateException("Not allowed.")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
override fun insert(p0: Uri, p1: ContentValues?): Uri? {
|
|
82
|
+
throw IllegalStateException("Not allowed.")
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
override fun delete(p0: Uri, p1: String?, p2: Array<out String>?): Int {
|
|
86
|
+
throw IllegalStateException("Not allowed.")
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
override fun update(p0: Uri, p1: ContentValues?, p2: String?, p3: Array<out String>?): Int {
|
|
90
|
+
throw IllegalStateException("Not allowed.")
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
companion object {
|
|
94
|
+
private lateinit var sInstance: FWInitializationProvider
|
|
95
|
+
|
|
96
|
+
val INSTANCE: FWInitializationProvider
|
|
97
|
+
get() = sInstance
|
|
98
|
+
}
|
|
99
|
+
}
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt
CHANGED
|
@@ -7,6 +7,7 @@ import com.loopnow.fireworklibrary.baya.Baya
|
|
|
7
7
|
import com.loopnow.fireworklibrary.baya.UpdateCartStatus
|
|
8
8
|
import com.fireworksdk.bridge.reactnative.models.FWVideoShoppingInterface
|
|
9
9
|
import com.fireworksdk.bridge.models.FWVideoShoppingProduct
|
|
10
|
+
import com.fireworksdk.bridge.reactnative.FWInitializationProvider
|
|
10
11
|
import com.fireworksdk.bridge.reactnative.pages.FWVideoShoppingCartActivity
|
|
11
12
|
import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
12
13
|
import com.fireworksdk.bridge.utils.FWJsonUtils
|
|
@@ -116,7 +117,7 @@ class FWVideoShoppingModule(
|
|
|
116
117
|
if (callbackId == null || cartClickHandler?.first != callbackId) {
|
|
117
118
|
return
|
|
118
119
|
}
|
|
119
|
-
val activity =
|
|
120
|
+
val activity = FWInitializationProvider.INSTANCE.resumedActivity ?: return
|
|
120
121
|
|
|
121
122
|
UiThreadUtil.runOnUiThread {
|
|
122
123
|
activity.startActivity(FWVideoShoppingCartActivity.createIntent(activity))
|
|
@@ -125,8 +126,11 @@ class FWVideoShoppingModule(
|
|
|
125
126
|
|
|
126
127
|
@ReactMethod
|
|
127
128
|
override fun exitCartPage() {
|
|
129
|
+
|
|
130
|
+
val activity = FWInitializationProvider.INSTANCE.resumedActivity ?: return
|
|
131
|
+
|
|
128
132
|
UiThreadUtil.runOnUiThread {
|
|
129
|
-
|
|
133
|
+
activity.finish()
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
|