Skip to content

Commit 1056b63

Browse files
authored
Fix: Resolves crash in Android (webView.engine is null) with Capacitor (#436)
1 parent dcf066e commit 1056b63

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/android/LottieSplashScreen.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ class LottieSplashScreen : CordovaPlugin() {
272272
animationView.addAnimatorListener(
273273
object : Animator.AnimatorListener {
274274
override fun onAnimationStart(animation: Animator) {
275-
webView.engine.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationStart'))") { }
275+
webView.engine?.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationStart'))") { }
276276
}
277277

278278
override fun onAnimationEnd(animation: Animator) {
279-
webView.engine.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationEnd'))") { }
279+
webView.engine?.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationEnd'))") { }
280280
val hideAfterAnimationDone = preferences.getBoolean(
281281
"LottieHideAfterAnimationEnd",
282282
false
@@ -288,11 +288,11 @@ class LottieSplashScreen : CordovaPlugin() {
288288
}
289289

290290
override fun onAnimationCancel(animation: Animator) {
291-
webView.engine.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationCancel'))") { }
291+
webView.engine?.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationCancel'))") { }
292292
}
293293

294294
override fun onAnimationRepeat(animation: Animator) {
295-
webView.engine.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationRepeat'))") { }
295+
webView.engine?.evaluateJavascript("document.dispatchEvent(new Event('lottieAnimationRepeat'))") { }
296296
}
297297
}
298298
)

0 commit comments

Comments
 (0)