陈嘉乐
2021-03-03 25ce81434a6ce69cf10f12d4f5a25ab80a339ba7
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
@@ -11,7 +11,7 @@
        /// <summary>
        /// 添加遥控器的方法
        /// </summary>
        public void AddControl(FrameLayout frameLayout)
        public void AddControl(FrameLayout frameLayout,Action<Control> action)
        {
            View.TipView tipView = new View.TipView();
            tipView.InputBox(frameLayout,"", (name, frame) => 
@@ -24,7 +24,7 @@
                    control.name = name;
                    control.type = "learn";
                    ThreadAddControl(control, frame,false);
                    ThreadAddControl(control, frame, action);
@@ -37,7 +37,7 @@
        /// </summary>
        /// <param name="control"></param>
        /// <param name="frame"></param>
        public void ThreadAddControl(Control control, FrameLayout frame,bool bool_library) {
        public void ThreadAddControl(Control control, FrameLayout frame,Action<Control> action) {
            DAL.Server.ResponsePackNew responsePackNew = null;
            Loading loading = new Loading();
@@ -47,7 +47,7 @@
            {
                try
                {
                    responsePackNew = PirSend.Add(control, bool_library);
                    responsePackNew = PirSend.Add(control);
                }
                catch { }
                finally
@@ -55,39 +55,31 @@
                    Application.RunOnMainThread(() =>
                    {
                        loading.Hide();
                        //if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                        //{
                        if (!string.IsNullOrEmpty(Sid("sid"))) { }
                        ///这里:监听MTTP推送下来主题,才知道是否添加成功
                        frame.RemoveFromParent();//添加成功关闭弹窗
                        if (bool_library) {
                            MainPage.BasePageView.RemoveViewByTag("PirView");
                            AddControlComplete addControlComplete = new AddControlComplete();
                            MainPage.BasePageView.AddChidren(addControlComplete);
                            addControlComplete.Show(control, bool_library);
                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                    {
                            if (!string.IsNullOrEmpty(Sid("sid")))
                            {
                                //监听Mqtt推送下来状态码做提示
                                View.FailView failView = new View.FailView();
                                failView.ShouError((view) =>
                                {
                                    view.Close();
                                    ThreadAddControl(control, frame, action);
                                });
                            }
                            else
                            {
                                ///这里:监听MTTP推送下来主题,才知道是否添加成功
                                frame.RemoveFromParent();//添加成功关闭弹窗
                                action(control);
                            }
                        }
                        else
                        {
                            AddButton addButton = new AddButton();
                            MainPage.BasePageView.AddChidren(addButton);
                            addButton.Show(control);
                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                            ErrorShow(responsePackNew);
                        }
                        //监听Mqtt推送下来状态码做提示
                        //View.FailView failView = new View.FailView();
                        //failView.ShouError((view) => {
                        //    view.Close();
                        //    ThreadAddControl(control, dialog);
                        //});
                        //}
                        //else
                        //{
                        //    ErrorShow(responsePackNew);
                        //}
                    });
                }
            })