/// <summary> /// Remove the observer for a given notifyContext from an observer list for a given Notification name. /// </summary> /// <param name="notificationName">which observer list to remove from</param> /// <param name="notifyContext">remove the observer with this object as its notifyContext</param> /// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks> public virtual void RemoveObserver(NotificationID notificationName, object notifyContext) { lock (m_syncRoot) { // the observer list for the notification under inspection if (m_observerMap.ContainsKey(notificationName)) { IList <IObserver> observers = m_observerMap[notificationName]; // find the observer for the notifyContext for (int i = 0; i < observers.Count; i++) { if (observers[i].CompareNotifyContext(notifyContext)) { // there can only be one Observer for a given notifyContext // in any given Observer list, so remove it and break observers.RemoveAt(i); break; } } // Also, when a Notification's Observer list length falls to // zero, delete the notification key from the observer map if (observers.Count == 0) { m_observerMap.Remove(notificationName); } } } }
/// <summary> /// Check if a Command is registered for a given Notification /// </summary> /// <param name="notificationName"></param> /// <returns>whether a Command is currently registered for the given <c>notificationName</c>.</returns> /// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks> public virtual bool HasCommand(NotificationID notificationName) { lock (m_syncRoot) { return(m_commandMap.ContainsKey(notificationName)); } }
private void OnClick(GameObject go) { Equip_Func_Type type = Equip_Func_Type.Null; NotificationID open_type = NotificationID.NULL; if (go.transform.name == "backBtn") { Facade.SendNotification(NotificationID.EquipMain_Hide); } switch (go.transform.name) { case "strongBtn": type = Equip_Func_Type.Strong; open_type = NotificationID.EquipStrong_Hide; break; case "starBtn": type = Equip_Func_Type.Star; open_type = NotificationID.EquipStar_Hide; break; case "insetBtn": type = Equip_Func_Type.Inset; open_type = NotificationID.EquipInset_Hide; break; case "inheritBtn": type = Equip_Func_Type.Inherit; open_type = NotificationID.EquipInherit_Hide; break; case "makeBtn": type = Equip_Func_Type.Make; open_type = NotificationID.EquipMake_Hide; break; case "compoundBtn": type = Equip_Func_Type.Compound; open_type = NotificationID.GemCompound_Hide; break; } if (open_type != cur_open_equip) { Facade.SendNotification(cur_open_equip); cur_open_equip = open_type; } if (type != cur_type) { cur_type = type; OpenFunction(); } }
/// <summary> /// Register an <c>IObserver</c> to be notified of <c>INotifications</c> with a given name /// </summary> /// <param name="notificationName">The name of the <c>INotifications</c> to notify this <c>IObserver</c> of</param> /// <param name="observer">The <c>IObserver</c> to register</param> /// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks> public virtual void RegisterObserver(NotificationID notificationName, IObserver observer) { lock (m_syncRoot) { if (!m_observerMap.ContainsKey(notificationName)) { m_observerMap[notificationName] = new List <IObserver>(); } m_observerMap[notificationName].Add(observer); } }
/// <summary> /// Register a particular <c>ICommand</c> class as the handler /// for a particular <c>INotification</c>. /// </summary> /// <param name="notificationName">The name of the <c>INotification</c></param> /// <param name="commandType">The <c>Type</c> of the <c>ICommand</c></param> /// <remarks> /// <para> /// If an <c>ICommand</c> has already been registered to /// handle <c>INotification</c>s with this name, it is no longer /// used, the new <c>ICommand</c> is used instead. /// </para> /// </remarks> /// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks> public virtual void RegisterCommand(NotificationID notificationName, Type commandType) { lock (m_syncRoot) { if (!m_commandMap.ContainsKey(notificationName)) { // This call needs to be monitored carefully. Have to make sure that RegisterObserver // doesn't call back into the controller, or a dead lock could happen. m_view.RegisterObserver(notificationName, new Observer("executeCommand", this)); } m_commandMap[notificationName] = commandType; } }
/// <summary> /// Remove a previously registered <c>ICommand</c> to <c>INotification</c> mapping. /// </summary> /// <param name="notificationName">The name of the <c>INotification</c> to remove the <c>ICommand</c> mapping for</param> /// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks> public virtual void RemoveCommand(NotificationID notificationName) { lock (m_syncRoot) { if (m_commandMap.ContainsKey(notificationName)) { // remove the observer // This call needs to be monitored carefully. Have to make sure that RemoveObserver // doesn't call back into the controller, or a dead lock could happen. m_view.RemoveObserver(notificationName, this); m_commandMap.Remove(notificationName); } } }
void SendNotification(string messageBody) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot); var notificationBuilder = new Notification.Builder(this) .SetVisibility(NotificationVisibility.Public) .SetSmallIcon(Resource.Drawable.ic_stat_ic_notification) .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.Icon)) .SetContentTitle(GetString(Resource.String.ApplicationName)) .SetContentText(messageBody) .SetAutoCancel(true) .SetContentIntent(pendingIntent); var notificationManager = NotificationManager.FromContext(this); notificationManager.Notify(NotificationID.GetID(), notificationBuilder.Build()); }
/// <summary> /// 界面显示 /// </summary> protected override void OnShow(INotification notification) { if (equipMediator == null) { equipMediator = Facade.RetrieveMediator("EquipMediator") as EquipMediator; } bool isHas = EquipConfig.IsHasEquip(); cur_type = isHas ? Equip_Func_Type.Strong : Equip_Func_Type.Make; cur_open_equip = isHas ? NotificationID.EquipStrong_Hide : NotificationID.EquipMake_Hide; Init(); RefreshBtnStates(); SetPlayerInfo(); SetEquipGridInfo(cur_select_player_id); OpenFunction(); }
/// <summary> /// 注册通知ID和处理函数 /// </summary> /// <param Name="notificationID"></param> /// <param Name="handle"></param> protected void RegistPanelCall(NotificationID notificationID, Action <INotification> handle) { interests.Add(notificationID); handleTable.Add(notificationID, handle); }
/// <summary> /// Lua打开界面 /// </summary> public static void OpenPanel(NotificationID notificationName) { Facade.Instance.SendNotification(notificationName); }
/// <summary> /// Send an <c>INotification</c> /// </summary> /// <param name="notificationName">The name of the notification to send</param> /// <param name="body">The body of the notification</param> /// <param name="type">The type of the notification</param> /// <remarks>Keeps us from having to construct new notification instances in our implementation code</remarks> /// <remarks>This method is thread safe</remarks> public virtual void SendNotification(NotificationID notificationName, object body, string type) { // The Facade SendNotification is thread safe, therefore this method is thread safe. m_facade.SendNotification(notificationName, body, type); }
/// <summary> /// Send an <c>INotification</c> /// </summary> /// <param name="notificationName">The name of the notiification to send</param> /// <remarks>Keeps us from having to construct new notification instances in our implementation code</remarks> /// <remarks>This method is thread safe</remarks> public virtual void SendNotification(NotificationID notificationName) { // The Facade SendNotification is thread safe, therefore this method is thread safe. m_facade.SendNotification(notificationName); }
public NotiData(NotificationID name, object param) { this.evName = name; this.evParam = param; }
/// <summary> /// Constructs a new notification with the specified name, body and type /// </summary> /// <param name="name">The name of the <c>Notification</c> instance</param> /// <param name="body">The <c>Notification</c>s body</param> /// <param name="type">The type of the <c>Notification</c></param> public Notification(NotificationID name, object body, string type) { m_name = name; m_body = body; m_type = type; }
/// <summary> /// Constructs a new notification with the specified name and body, with the default type /// </summary> /// <param name="name">The name of the <c>Notification</c> instance</param> /// <param name="body">The <c>Notification</c>s body</param> public Notification(NotificationID name, object body) : this(name, body, null) { }
/// <summary> /// Constructs a new notification with the specified name, default body and type /// </summary> /// <param name="name">The name of the <c>Notification</c> instance</param> public Notification(NotificationID name) : this(name, null, null) { }
private void ResetInfo() { cur_type = Equip_Func_Type.Strong; cur_open_equip = NotificationID.EquipStrong_Hide; cur_equip = null; }
protected void UnRegistPanelCall(NotificationID notificationID) { interests.Remove(notificationID); handleTable.Remove(notificationID); }
/// <summary> /// Send an <c>INotification</c> /// </summary> /// <param name="notificationName">The name of the notification to send</param> /// <param name="body">The body of the notification</param> /// <param name="type">The type of the notification</param> /// <remarks>Keeps us from having to construct new notification instances in our implementation code</remarks> /// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks> public virtual void SendNotification(NotificationID notificationName, object body, string type) { NotifyObservers(new Notification(notificationName, body, type)); }
/// <summary> /// Send an <c>INotification</c> /// </summary> /// <param name="notificationName">The name of the notiification to send</param> /// <remarks>Keeps us from having to construct new notification instances in our implementation code</remarks> /// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks> public virtual void SendNotification(NotificationID notificationName) { NotifyObservers(new Notification(notificationName)); }
/// <summary> /// Check if a Command is registered for a given Notification /// </summary> /// <param name="notificationName">The name of the <c>INotification</c> to check for.</param> /// <returns>whether a Command is currently registered for the given <c>notificationName</c>.</returns> /// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks> public virtual bool HasCommand(NotificationID notificationName) { // The controller is initialized in the constructor of the singleton, so this call should be thread safe. // This method is thread safe on the controller. return(m_controller.HasCommand(notificationName)); }
/// <summary> /// Remove a previously registered <c>ICommand</c> to <c>INotification</c> mapping from the Controller. /// </summary> /// <param name="notificationName">TRemove a previously registered <c>ICommand</c> to <c>INotification</c> mapping from the Controller.</param> /// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks> public virtual void RemoveCommand(NotificationID notificationName) { // The controller is initialized in the constructor of the singleton, so this call should be thread safe. // This method is thread safe on the controller. m_controller.RemoveCommand(notificationName); }