react-native-nitro-simple-toast 0.1.0 → 0.1.1-beta.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.
|
@@ -8,12 +8,13 @@ import android.os.Vibrator
|
|
|
8
8
|
import android.os.VibratorManager
|
|
9
9
|
import android.widget.Toast
|
|
10
10
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
11
|
+
import com.margelo.nitro.NitroModules
|
|
11
12
|
|
|
12
13
|
@DoNotStrip
|
|
13
14
|
class NitroSimpleToast : HybridNitroSimpleToastSpec() {
|
|
14
15
|
|
|
15
16
|
override fun show(options: ToastOptions): Unit {
|
|
16
|
-
val context =
|
|
17
|
+
val context = NitroModules.applicationContext ?: return
|
|
17
18
|
|
|
18
19
|
Handler(Looper.getMainLooper()).post {
|
|
19
20
|
val text = if (options.message != null) {
|
|
@@ -38,7 +39,7 @@ class NitroSimpleToast : HybridNitroSimpleToastSpec() {
|
|
|
38
39
|
private fun performHaptic(haptic: ToastHaptic) {
|
|
39
40
|
if (haptic == ToastHaptic.NONE) return
|
|
40
41
|
|
|
41
|
-
val context =
|
|
42
|
+
val context = NitroModules.applicationContext ?: return
|
|
42
43
|
|
|
43
44
|
val vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
44
45
|
val vibratorManager = context.getSystemService(
|
|
@@ -7,7 +7,6 @@ import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
|
7
7
|
|
|
8
8
|
class NitroSimpleToastPackage : BaseReactPackage() {
|
|
9
9
|
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
10
|
-
appContext = reactContext
|
|
11
10
|
return null
|
|
12
11
|
}
|
|
13
12
|
|
|
@@ -19,8 +18,5 @@ class NitroSimpleToastPackage : BaseReactPackage() {
|
|
|
19
18
|
init {
|
|
20
19
|
System.loadLibrary("nitrosimpletoast")
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
@Volatile
|
|
24
|
-
var appContext: ReactApplicationContext? = null
|
|
25
21
|
}
|
|
26
22
|
}
|
package/package.json
CHANGED