-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrated java PurchasesFlutterPlugin class to kotlin class. #686
base: main
Are you sure you want to change the base?
Migrated java PurchasesFlutterPlugin class to kotlin class. #686
Conversation
2. Moved method names and argument names in constant file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be registrar?.activity() ?: activity
I think?
store = Store.AMAZON | ||
} | ||
configure( | ||
applicationContext!!, apiKey!!, appUserID, observerMode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to update to use the latest version of the plugin.
What does this pr do?