Pigeon: Integrated showCastDialog API in Android and iOS
This commit is contained in:
parent
f7f5cc679a
commit
3768c925b2
4 changed files with 18 additions and 25 deletions
|
|
@ -153,22 +153,8 @@ class FlutterCastFrameworkPlugin : FlutterPlugin, MethodCallHandler, ActivityAwa
|
|||
//endregion
|
||||
|
||||
override fun onMethodCall(call: MethodCall, result: Result) {
|
||||
val method = call.method
|
||||
val arguments = call.arguments
|
||||
|
||||
when (method) {
|
||||
MethodNames.showCastDialog -> {
|
||||
val context = applicationContext
|
||||
val activity = this.activity
|
||||
if (context == null || activity == null) {
|
||||
Log.d(TAG, "onMethodCall - missing context")
|
||||
return
|
||||
}
|
||||
|
||||
CastDialogOpener.showCastDialog(context, activity)
|
||||
}
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
Log.d(TAG, "onMethodCall - ${call.method} not implemented")
|
||||
result.notImplemented()
|
||||
}
|
||||
|
||||
private inner class MyApi : HostApis.CastApi {
|
||||
|
|
@ -176,6 +162,16 @@ class FlutterCastFrameworkPlugin : FlutterPlugin, MethodCallHandler, ActivityAwa
|
|||
mMessageCastingChannel?.sendMessage(mCastSession, message)
|
||||
}
|
||||
|
||||
override fun showCastDialog() {
|
||||
val context = applicationContext
|
||||
val activity = activity
|
||||
if (context == null || activity == null) {
|
||||
Log.d(TAG, "showCastDialog - missing context")
|
||||
return
|
||||
}
|
||||
|
||||
CastDialogOpener.showCastDialog(context, activity)
|
||||
}
|
||||
}
|
||||
|
||||
private inner class NamespaceResult(val oldSession: CastSession?, val newSession: CastSession?) : Result {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.gianlucaparadise.flutter_cast_framework
|
|||
|
||||
object MethodNames {
|
||||
const val onCastStateChanged = "CastContext.onCastStateChanged"
|
||||
const val showCastDialog = "showCastDialog"
|
||||
|
||||
// region SessionManager
|
||||
const val onSessionStarting = "SessionManager.onSessionStarting"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import Foundation
|
|||
|
||||
enum MethodNames : String {
|
||||
case onCastStateChanged = "CastContext.onCastStateChanged"
|
||||
case showCastDialog = "showCastDialog"
|
||||
|
||||
// region SessionManager
|
||||
case onSessionStarting = "SessionManager.onSessionStarting"
|
||||
|
|
|
|||
|
|
@ -111,13 +111,8 @@ public class SwiftFlutterCastFrameworkPlugin: NSObject, FlutterPlugin, GCKSessio
|
|||
}
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
case MethodNames.showCastDialog.rawValue:
|
||||
castContext.presentCastDialog()
|
||||
default:
|
||||
print("Method [\(call.method)] is not implemented.")
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
castStateObserver?.invalidate()
|
||||
|
|
@ -129,6 +124,10 @@ public class SwiftFlutterCastFrameworkPlugin: NSObject, FlutterPlugin, GCKSessio
|
|||
MessageCastingChannel.sendMessage(allCastingChannels: self.castingChannels, castMessage: message)
|
||||
}
|
||||
|
||||
public func showCastDialogWithError(_ error: AutoreleasingUnsafeMutablePointer<FlutterError?>) {
|
||||
castContext.presentCastDialog()
|
||||
}
|
||||
|
||||
// MARK: - GCKSessionManagerListener
|
||||
|
||||
// onSessionSuspended
|
||||
|
|
|
|||
Loading…
Reference in a new issue