-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from stevenosse/use-kotlin
Use kotlin for generated bindings
- Loading branch information
Showing
8 changed files
with
141 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ migrate_working_dir/ | |
.dart_tool/ | ||
.packages | ||
build/ | ||
|
||
.fvm/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 0 additions & 147 deletions
147
android/src/main/java/sncf/connect/tech/flutter_google_wallet/Messages.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
android/src/main/kotlin/sncf/connect/tech/flutter_google_wallet/Messages.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Autogenerated from Pigeon (v10.0.0), do not edit directly. | ||
// See also: https://pub.dev/packages/pigeon | ||
|
||
package sncf.connect.tech.flutter_google_wallet | ||
|
||
import android.util.Log | ||
import io.flutter.plugin.common.BasicMessageChannel | ||
import io.flutter.plugin.common.BinaryMessenger | ||
import io.flutter.plugin.common.MessageCodec | ||
import io.flutter.plugin.common.StandardMessageCodec | ||
import java.io.ByteArrayOutputStream | ||
import java.nio.ByteBuffer | ||
|
||
private fun wrapResult(result: Any?): List<Any?> { | ||
return listOf(result) | ||
} | ||
|
||
private fun wrapError(exception: Throwable): List<Any?> { | ||
if (exception is FlutterError) { | ||
return listOf( | ||
exception.code, | ||
exception.message, | ||
exception.details | ||
) | ||
} else { | ||
return listOf( | ||
exception.javaClass.simpleName, | ||
exception.toString(), | ||
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception) | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* Error class for passing custom error details to Flutter via a thrown PlatformException. | ||
* @property code The error code. | ||
* @property message The error message. | ||
* @property details The error details. Must be a datatype supported by the api codec. | ||
*/ | ||
class FlutterError ( | ||
val code: String, | ||
override val message: String? = null, | ||
val details: Any? = null | ||
) : Throwable() | ||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */ | ||
interface GoogleWalletApi { | ||
fun initWalletClient() | ||
fun getWalletApiAvailabilityStatus(): Boolean | ||
fun savePasses(jsonPass: String, addToGoogleWalletRequestCode: Long) | ||
|
||
companion object { | ||
/** The codec used by GoogleWalletApi. */ | ||
val codec: MessageCodec<Any?> by lazy { | ||
StandardMessageCodec() | ||
} | ||
/** Sets up an instance of `GoogleWalletApi` to handle messages through the `binaryMessenger`. */ | ||
@Suppress("UNCHECKED_CAST") | ||
fun setUp(binaryMessenger: BinaryMessenger, api: GoogleWalletApi?) { | ||
run { | ||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.GoogleWalletApi.initWalletClient", codec) | ||
if (api != null) { | ||
channel.setMessageHandler { _, reply -> | ||
var wrapped: List<Any?> | ||
try { | ||
api.initWalletClient() | ||
wrapped = listOf<Any?>(null) | ||
} catch (exception: Throwable) { | ||
wrapped = wrapError(exception) | ||
} | ||
reply.reply(wrapped) | ||
} | ||
} else { | ||
channel.setMessageHandler(null) | ||
} | ||
} | ||
run { | ||
val taskQueue = binaryMessenger.makeBackgroundTaskQueue() | ||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.GoogleWalletApi.getWalletApiAvailabilityStatus", codec, taskQueue) | ||
if (api != null) { | ||
channel.setMessageHandler { _, reply -> | ||
var wrapped: List<Any?> | ||
try { | ||
wrapped = listOf<Any?>(api.getWalletApiAvailabilityStatus()) | ||
} catch (exception: Throwable) { | ||
wrapped = wrapError(exception) | ||
} | ||
reply.reply(wrapped) | ||
} | ||
} else { | ||
channel.setMessageHandler(null) | ||
} | ||
} | ||
run { | ||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.GoogleWalletApi.savePasses", codec) | ||
if (api != null) { | ||
channel.setMessageHandler { message, reply -> | ||
val args = message as List<Any?> | ||
val jsonPassArg = args[0] as String | ||
val addToGoogleWalletRequestCodeArg = args[1].let { if (it is Int) it.toLong() else it as Long } | ||
var wrapped: List<Any?> | ||
try { | ||
api.savePasses(jsonPassArg, addToGoogleWalletRequestCodeArg) | ||
wrapped = listOf<Any?>(null) | ||
} catch (exception: Throwable) { | ||
wrapped = wrapError(exception) | ||
} | ||
reply.reply(wrapped) | ||
} | ||
} else { | ||
channel.setMessageHandler(null) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
dart pub run pigeon \ | ||
--input pigeons/messages.dart \ | ||
--dart_out lib/messages.dart \ | ||
--java_out android/src/main/java/sncf/connect/tech/flutter_google_wallet/Messages.java \ | ||
--java_package "sncf.connect.tech.flutter_google_wallet" | ||
--input pigeons/messages.dart \ | ||
--dart_out lib/messages.dart \ | ||
--kotlin_out android/src/main/kotlin/sncf/connect/tech/flutter_google_wallet/Messages.kt \ | ||
--kotlin_package "sncf.connect.tech.flutter_google_wallet" |