public override void onDetach() { base.onDetach(); Log.i(LOGTAG, "On detach Subscriber control fragment"); mCallbacks = sOpenTokCallbacks; }
public override void onAttach(Activity activity) { base.onAttach(activity); Log.i(LOGTAG, "On attach Subscriber control fragment"); openTokActivity = (UIActivity)activity; if (!(activity is SubscriberCallbacks)) { throw new System.InvalidOperationException("Activity must implement fragment's callback"); } mCallbacks = (SubscriberCallbacks)activity; }
public override void onAttach(Activity activity) { base.onAttach(activity); Log.i(LOGTAG, "On attach Subscriber control fragment"); openTokActivity = (UIActivity) activity; if (!(activity is SubscriberCallbacks)) { throw new System.InvalidOperationException("Activity must implement fragment's callback"); } mCallbacks = (SubscriberCallbacks) activity; }
public void AddSubscriber <DataType>(string topic, Subscriber <DataType> subscriber) { var bridgeType = Plugin.GetBridgeType <DataType>(); if (bridgeType == null) { throw new Exception($"Unknown data type {typeof(DataType).Name} used for subscriber in {Plugin.Name} bridge"); } SubscriberData.Add(new TopicData(topic, bridgeType)); if (Subscribers.TryGetValue(topic, out var sub)) { lock (sub) { sub.Callbacks.Add(subscriber); } return; } sub = new SubscriberCallbacks(); sub.Callbacks.Add(subscriber); var subCreator = Plugin.GetCreateSubscriber <DataType>(); if (subCreator == null) { throw new NotSupportedException($"Subscriber on {topic} topic for for {typeof(DataType).Name} not supported by {Plugin.Name} bridge"); } subCreator(Instance, topic, data => { foreach (var s in SubscriberData) { if (s.Topic == topic) { s.Count += 1; } } lock (sub) { sub.Callbacks.ForEach(cb => Actions.Enqueue(() => (cb as Subscriber <DataType>)(data))); } }); Subscribers.Add(topic, sub); }
public override void onDetach() { base.onDetach(); Log.i(LOGTAG, "On detach Subscriber control fragment"); mCallbacks = sOpenTokCallbacks; }