Pigeon: Used renamed APIs
- Renamed from `HostApis` to `PlatformBridgeApis`
This commit is contained in:
parent
1dd9ab2370
commit
f5aefbcec1
7 changed files with 27 additions and 28 deletions
|
|
@ -18,7 +18,6 @@ import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||||
import io.flutter.plugin.common.BinaryMessenger
|
import io.flutter.plugin.common.BinaryMessenger
|
||||||
import io.flutter.plugin.common.MethodCall
|
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.MethodCallHandler
|
||||||
import io.flutter.plugin.common.MethodChannel.Result
|
import io.flutter.plugin.common.MethodChannel.Result
|
||||||
import io.flutter.plugin.common.PluginRegistry.Registrar
|
import io.flutter.plugin.common.PluginRegistry.Registrar
|
||||||
|
|
@ -49,9 +48,9 @@ class FlutterCastFrameworkPlugin : FlutterPlugin, MethodCallHandler, ActivityAwa
|
||||||
this.applicationContext = applicationContext
|
this.applicationContext = applicationContext
|
||||||
|
|
||||||
castApi = MyApi()
|
castApi = MyApi()
|
||||||
HostApis.CastApi.setup(messenger, castApi)
|
PlatformBridgeApis.CastHostApi.setup(messenger, castApi)
|
||||||
|
|
||||||
val castFlutterApi = HostApis.CastFlutterApi(messenger)
|
val castFlutterApi = PlatformBridgeApis.CastFlutterApi(messenger)
|
||||||
flutterApi = castFlutterApi
|
flutterApi = castFlutterApi
|
||||||
|
|
||||||
mMessageCastingChannel = MessageCastingChannel(castFlutterApi)
|
mMessageCastingChannel = MessageCastingChannel(castFlutterApi)
|
||||||
|
|
@ -97,8 +96,8 @@ class FlutterCastFrameworkPlugin : FlutterPlugin, MethodCallHandler, ActivityAwa
|
||||||
private lateinit var mSessionManager: SessionManager
|
private lateinit var mSessionManager: SessionManager
|
||||||
private val mSessionManagerListener = CastSessionManagerListener()
|
private val mSessionManagerListener = CastSessionManagerListener()
|
||||||
|
|
||||||
private var castApi : HostApis.CastApi? = null
|
private var castApi : PlatformBridgeApis.CastHostApi? = null
|
||||||
private var flutterApi: HostApis.CastFlutterApi? = null
|
private var flutterApi: PlatformBridgeApis.CastFlutterApi? = null
|
||||||
private var applicationContext: Context? = null
|
private var applicationContext: Context? = null
|
||||||
private var activity: Activity? = null
|
private var activity: Activity? = null
|
||||||
|
|
||||||
|
|
@ -153,8 +152,8 @@ class FlutterCastFrameworkPlugin : FlutterPlugin, MethodCallHandler, ActivityAwa
|
||||||
result.notImplemented()
|
result.notImplemented()
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class MyApi : HostApis.CastApi {
|
private inner class MyApi : PlatformBridgeApis.CastHostApi {
|
||||||
override fun sendMessage(message: HostApis.CastMessage?) {
|
override fun sendMessage(message: PlatformBridgeApis.CastMessage?) {
|
||||||
mMessageCastingChannel?.sendMessage(mCastSession, message)
|
mMessageCastingChannel?.sendMessage(mCastSession, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,7 +169,7 @@ class FlutterCastFrameworkPlugin : FlutterPlugin, MethodCallHandler, ActivityAwa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getOnNamespaceResult(oldSession: CastSession?, newSession: CastSession?) = HostApis.CastFlutterApi.Reply<MutableList<String>> { namespaces ->
|
private fun getOnNamespaceResult(oldSession: CastSession?, newSession: CastSession?) = PlatformBridgeApis.CastFlutterApi.Reply<MutableList<String>> { namespaces ->
|
||||||
Log.d(TAG, "Updating mCastSession - getOnNamespaceResult - param: $namespaces")
|
Log.d(TAG, "Updating mCastSession - getOnNamespaceResult - param: $namespaces")
|
||||||
if (oldSession == null && newSession == null) return@Reply // nothing to do here
|
if (oldSession == null && newSession == null) return@Reply // nothing to do here
|
||||||
if (namespaces == null || !namespaces.any()) return@Reply // nothing to do here
|
if (namespaces == null || !namespaces.any()) return@Reply // nothing to do here
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
package com.gianlucaparadise.flutter_cast_framework.cast
|
package com.gianlucaparadise.flutter_cast_framework.cast
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.gianlucaparadise.flutter_cast_framework.HostApis
|
import com.gianlucaparadise.flutter_cast_framework.PlatformBridgeApis
|
||||||
import com.google.android.gms.cast.Cast
|
import com.google.android.gms.cast.Cast
|
||||||
import com.google.android.gms.cast.CastDevice
|
import com.google.android.gms.cast.CastDevice
|
||||||
import com.google.android.gms.cast.framework.CastSession
|
import com.google.android.gms.cast.framework.CastSession
|
||||||
|
|
||||||
class MessageCastingChannel(private val flutterApi : HostApis.CastFlutterApi) : Cast.MessageReceivedCallback {
|
class MessageCastingChannel(private val flutterApi : PlatformBridgeApis.CastFlutterApi) : Cast.MessageReceivedCallback {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "MessageCastingChannel"
|
const val TAG = "MessageCastingChannel"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMessageReceived(castDevice: CastDevice?, namespace: String?, message: String?) {
|
override fun onMessageReceived(castDevice: CastDevice?, namespace: String?, message: String?) {
|
||||||
Log.d(TAG, "Message received: $message:")
|
Log.d(TAG, "Message received: $message:")
|
||||||
val castMessage = HostApis.CastMessage()
|
val castMessage = PlatformBridgeApis.CastMessage()
|
||||||
castMessage.namespace = namespace
|
castMessage.namespace = namespace
|
||||||
castMessage.message = message
|
castMessage.message = message
|
||||||
|
|
||||||
flutterApi.onMessageReceived(castMessage) {}
|
flutterApi.onMessageReceived(castMessage) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendMessage(castSession: CastSession?, castMessage: HostApis.CastMessage?) {
|
fun sendMessage(castSession: CastSession?, castMessage: PlatformBridgeApis.CastMessage?) {
|
||||||
Log.d(TAG, "Send Message arguments: $castMessage:")
|
Log.d(TAG, "Send Message arguments: $castMessage:")
|
||||||
if (castMessage == null) return
|
if (castMessage == null) return
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#import <Flutter/Flutter.h>
|
#import <Flutter/Flutter.h>
|
||||||
#import "HostApis.h"
|
#import "PlatformBridgeApis.h"
|
||||||
|
|
||||||
@interface FlutterCastFrameworkPlugin : NSObject<FlutterPlugin>
|
@interface FlutterCastFrameworkPlugin : NSObject<FlutterPlugin>
|
||||||
@end
|
@end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import Flutter
|
||||||
import UIKit
|
import UIKit
|
||||||
import GoogleCast
|
import GoogleCast
|
||||||
|
|
||||||
public class SwiftFlutterCastFrameworkPlugin: NSObject, FlutterPlugin, GCKSessionManagerListener, CastApi {
|
public class SwiftFlutterCastFrameworkPlugin: NSObject, FlutterPlugin, GCKSessionManagerListener, CastHostApi {
|
||||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||||
let messenger : FlutterBinaryMessenger = registrar.messenger()
|
let messenger : FlutterBinaryMessenger = registrar.messenger()
|
||||||
let flutterApi = CastFlutterApi.init(binaryMessenger: messenger)
|
let flutterApi = CastFlutterApi.init(binaryMessenger: messenger)
|
||||||
|
|
@ -12,8 +12,8 @@ public class SwiftFlutterCastFrameworkPlugin: NSObject, FlutterPlugin, GCKSessio
|
||||||
let channel = FlutterMethodChannel(name: "flutter_cast_framework_dummy_channel", binaryMessenger: messenger)
|
let channel = FlutterMethodChannel(name: "flutter_cast_framework_dummy_channel", binaryMessenger: messenger)
|
||||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||||
|
|
||||||
let api : CastApi & NSObjectProtocol = instance
|
let api : CastHostApi & NSObjectProtocol = instance
|
||||||
CastApiSetup(messenger, api)
|
CastHostApiSetup(messenger, api)
|
||||||
}
|
}
|
||||||
|
|
||||||
private let castContext: GCKCastContext
|
private let castContext: GCKCastContext
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import '../HostApis.dart';
|
import '../PlatformBridgeApis.dart';
|
||||||
import 'SessionManager.dart';
|
import 'SessionManager.dart';
|
||||||
|
|
||||||
class CastContext {
|
class CastContext {
|
||||||
final ValueNotifier<CastState> state = ValueNotifier(CastState.unavailable);
|
final ValueNotifier<CastState> state = ValueNotifier(CastState.unavailable);
|
||||||
final CastApi castApi;
|
final CastHostApi hostApi;
|
||||||
|
|
||||||
CastContext(this.castApi);
|
CastContext(this.hostApi);
|
||||||
|
|
||||||
void showCastChooserDialog() {
|
void showCastChooserDialog() {
|
||||||
castApi.showCastDialog();
|
hostApi.showCastDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onCastStateChanged(int castState) {
|
void onCastStateChanged(int castState) {
|
||||||
|
|
@ -20,7 +20,7 @@ class CastContext {
|
||||||
SessionManager get sessionManager {
|
SessionManager get sessionManager {
|
||||||
var result = _sessionManager;
|
var result = _sessionManager;
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
_sessionManager = result = SessionManager(castApi);
|
_sessionManager = result = SessionManager(hostApi);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import '../HostApis.dart';
|
import '../PlatformBridgeApis.dart';
|
||||||
|
|
||||||
class SessionManager {
|
class SessionManager {
|
||||||
final CastApi castApi;
|
final CastHostApi hostApi;
|
||||||
|
|
||||||
SessionManager(this.castApi);
|
SessionManager(this.hostApi);
|
||||||
|
|
||||||
final ValueNotifier<SessionState> state = ValueNotifier(SessionState.idle);
|
final ValueNotifier<SessionState> state = ValueNotifier(SessionState.idle);
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ class SessionManager {
|
||||||
final castMessage = CastMessage();
|
final castMessage = CastMessage();
|
||||||
castMessage.namespace = namespace;
|
castMessage.namespace = namespace;
|
||||||
castMessage.message = message;
|
castMessage.message = message;
|
||||||
castApi.sendMessage(castMessage);
|
hostApi.sendMessage(castMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import 'package:flutter_cast_framework/cast.dart';
|
import 'package:flutter_cast_framework/cast.dart';
|
||||||
|
|
||||||
import 'HostApis.dart';
|
import 'PlatformBridgeApis.dart';
|
||||||
import 'cast/CastContext.dart';
|
import 'cast/CastContext.dart';
|
||||||
|
|
||||||
class FlutterCastFramework {
|
class FlutterCastFramework {
|
||||||
static final castApi = CastApi();
|
static final hostApi = CastHostApi();
|
||||||
|
|
||||||
/// List of namespaces to listen for custom messages
|
/// List of namespaces to listen for custom messages
|
||||||
static List<String> namespaces = [];
|
static List<String> namespaces = [];
|
||||||
|
|
@ -21,7 +21,7 @@ class FlutterCastFramework {
|
||||||
static CastContext get castContext {
|
static CastContext get castContext {
|
||||||
var castContext = _castContext;
|
var castContext = _castContext;
|
||||||
if (!_isInitiated || castContext == null) {
|
if (!_isInitiated || castContext == null) {
|
||||||
_castContext = castContext = CastContext(castApi);
|
_castContext = castContext = CastContext(hostApi);
|
||||||
// TODO: find a better way to init the plugin
|
// TODO: find a better way to init the plugin
|
||||||
_isInitiated = true;
|
_isInitiated = true;
|
||||||
_init();
|
_init();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue