Migrated java PurchasesFlutterPlugin class to kotlin class.#686
Migrated java PurchasesFlutterPlugin class to kotlin class.#686Arunshaik2001 wants to merge 1 commit intoRevenueCat:mainfrom
Conversation
2. Moved method names and argument names in constant file
tonidero
left a comment
There was a problem hiding this comment.
Hi @Arunshaik2001, really sorry for taking so long to answer.
We definitely would like to move this code to Kotlin! So this is a great contribution, thanks! I left a few comments here, let me know if you have any questions or anything I can help with!
|
|
||
| internal object Constants { | ||
|
|
||
| object MethodNameConstants{ |
There was a problem hiding this comment.
We believe extracting all these constants doesn't provide much value and can even decrease legibility. The exception to this would be when they are repeated. Could you move the constants back to the plugin class? It would be fine to leave any that are repeated.
|
|
||
| override fun onDetachedFromEngine(binding: FlutterPluginBinding) { | ||
| if (channel != null) { | ||
| channel!!.setMethodCallHandler(null) |
There was a problem hiding this comment.
Could this be channel?.setMethodCallHandler(null)
| } | ||
|
|
||
| private fun getActivity(): Activity? { | ||
| return if (registrar != null) registrar!!.activity() else activity |
There was a problem hiding this comment.
This could be registrar?.activity() ?: activity I think?
| store = Store.AMAZON | ||
| } | ||
| configure( | ||
| applicationContext!!, apiKey!!, appUserID, observerMode, |
There was a problem hiding this comment.
Instead of crashing here, it would be better to try to handle this gracefully by calling result.error (I understand it would have crashes with the Java version as well, but we can improve that now)
| type: String?, | ||
| result: MethodChannel.Result | ||
| ) { | ||
| getProductInfo(productIDs, type!!, object : OnResultList { |
There was a problem hiding this comment.
Same here and other places we use !!. Ideally we handle it gracefully
| private fun invokeChannelMethodOnUiThread(method: String, argumentsMap: Any) { | ||
| runOnUiThread { | ||
| if (channel != null) { | ||
| channel!!.invokeMethod(method, argumentsMap) |
There was a problem hiding this comment.
This could be channel?.invokeMethod(method, argumentsMap)
| private const val CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated" | ||
| protected const val LOG_HANDLER_EVENT = "Purchases-LogHandlerEvent" | ||
| private const val PLATFORM_NAME = "flutter" | ||
| private const val PLUGIN_VERSION = "4.13.0-SNAPSHOT" |
There was a problem hiding this comment.
We will need to update to use the latest version of the plugin.
What does this pr do?