Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
Aa fix crash template creation (#2)
Browse files Browse the repository at this point in the history
* FIx missing even didPressMenuItem

* add checker to avoid crash when uninitialized

* fix loading AA screen
  • Loading branch information
sonnguyen-tma authored Jun 24, 2024
1 parent be9629a commit e1fcf67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ class CarPlayModule internal constructor(private val reactContext: ReactApplicat

@ReactMethod
fun toast(text: String, duration: Int) {
if (!::carContext.isInitialized) {
Log.e(TAG, "carContext is not initialized. Cannot show toast.")
return
}
CarToast.makeText(carContext, text, duration).show()
}

Expand Down Expand Up @@ -271,6 +275,10 @@ class CarPlayModule internal constructor(private val reactContext: ReactApplicat
}

private fun createScreen(templateId: String): CarScreen? {
if (!::carContext.isInitialized) {
Log.e(TAG, "carContext not initialized")
return null
}
val config = carTemplates[templateId];
if (config != null) {
val screen = CarScreen(carContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CarPlaySession(private val reactInstanceManager: ReactInstanceManager) : S
invokeStartTask(reactInstanceManager.currentReactContext!!);
}
}
}, IntentFilter("org.birkir.carplay.APP_RELOAD"))
}, IntentFilter("org.birkir.carplay.APP_RELOAD"), Context.RECEIVER_EXPORTED)

// Run JS
runJsApplication()
Expand Down

0 comments on commit e1fcf67

Please sign in to comment.