Skip to content
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

Update TobiasPlugin.kt #123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions android/src/main/kotlin/com/jarvan/tobias/TobiasPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,42 @@ package com.jarvan.tobias
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import io.flutter.plugin.common.PluginRegistry

class TobiasPlugin : FlutterPlugin, MethodCallHandler, ActivityAware{
class TobiasPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {

private val delegate = TobaisPluginDelegate()

override fun onMethodCall(call: MethodCall, result: Result) = delegate.handleMethodCall(call, result)
override fun onMethodCall(call: MethodCall, result: Result) =
delegate.handleMethodCall(call, result)

companion object {
/**
* Plugin registration.
*/
@SuppressWarnings("deprecation")
public fun registerWith(registrar: PluginRegistry.Registrar) {
val instance = TobiasPlugin()
instance.onAttachedToEngine(registrar.messenger())
}
}

override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
val channel = MethodChannel(binding.binaryMessenger, "com.jarvanmo/tobias")
onAttachedToEngine(binding.binaryMessenger);
}


private fun onAttachedToEngine(messenger: BinaryMessenger) {
val channel = MethodChannel(messenger, "com.jarvanmo/tobias")
channel.setMethodCallHandler(this)
}


override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
delegate.cancel()
}
Expand Down