From adf7df175e590b7d9e0f33c0c2ea1d2897da6301 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 29 三月 2023 14:33:12 +0800
Subject: [PATCH] Merge branch 'dev-cqy(1.5.9)' into wjc

---
 HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs |  359 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 258 insertions(+), 101 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs
index f07cff2..fc60e23 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs
@@ -2,6 +2,10 @@
 using HDL_ON.Entity;
 using System.Collections.Generic;
 using Shared;
+#if __IOS__
+#else
+using Com.Videogo.Hdl;
+#endif
 
 namespace HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock
 {
@@ -11,8 +15,15 @@
     public class CommonMethod
     {
         private Loading loading;
-        private static CommonMethod commonMethod = null;
+        /// <summary>
+        /// 璁板綍褰撳墠鐣岄潰绱㈠紩鍊�
+        /// </summary>
+        private int pageLayoutIndexValue;
 
+        private static CommonMethod commonMethod = null;
+        /// <summary>
+        /// 鑾峰彇瀵硅薄
+        /// </summary>
         public static CommonMethod Current
         {
             get
@@ -28,33 +39,71 @@
 
         }
 
-        #region  --------- 璺宠浆鍒癆ndroid閭h竟鐨勬柟娉�(钀ょ煶瑙嗛闂ㄩ攣) --------
+        #region  --------- 璺宠浆鍒癆ndroid锛宨os閭h竟鐨勬柟娉�(钀ょ煶瑙嗛闂ㄩ攣) --------
         /// <summary>
-        /// 娣诲姞璁惧鍒颁簯绔�
-        /// <paramref name="devSerial"/>璁惧搴忓垪鍙�</param>
-        /// </summary>
-        public void SkipAddDeviceActivity(string devSerial)
+        /// android,ios婧愮敓娣诲姞璁惧鍒颁簯绔垚鍔熷悗鍥炶皟鏂规硶
+        /// 鍐嶈鍙栦簯绔殑涓婅悿鐭宠澶囧垪琛�
+        /// <paramref name="spk"/>spk</param>
+        public void SkipAddDeviceActivity(string spk)
         {
-            if (string.IsNullOrEmpty(devSerial)) return;
-            new System.Threading.Thread(() =>
+
+            this.InitializationAndroidData((isBools) =>
             {
-                var list = VideDoorLockSend.Current.GetVideoDoorLockDeviceList(SPK.VideoDoorLock);
-                if (list.Count > 0)
+
+                this.MainThread(() =>
                 {
-                    var function = list.Find((o) => o.sid == devSerial);
-                    if (function != null)
+                    if (!isBools)
                     {
-                        this.SaveFunctionFile(function);
+                        this.ShowTip("鍏堣幏鍙栬悿鐭充簯瀛愯处鍙穞oken澶辫触銆�");
                     }
-                }
-            })
-            { IsBackground = true }.Start();
-            //鏈疄鐜�
 #if __IOS__
+                //璺宠浆娣诲姞钀ょ煶璁惧
+                ezsdkDelegate = new IosIHdlInterface();
+                ezsdkDelegate.mAction += (serials) => {
+                    var list = VideDoorLockSend.Current.GetVideoDoorLockDeviceList(SPK.VideoDoorLock);
+                    if (list.Count > 0)
+                    {
+                        var function = list.Find((o) => o.sid == serials);
+                        if (function != null)
+                        {
+                            this.SaveFunctionFile(function);
+                        }
+                    }
+                };
+                EZSDK.IOS.EZSDK.SharedInstance().Delegate= ezsdkDelegate;
+                EZSDK.IOS.EZSDK.SharedInstance().AddEzvizMonitorWithDeviceType(spk);
 
 #else
+                HDLEzvizSdk.Instance.JumpToEZScanActivity(Application.Activity,spk);
+                HDLEzvizSdk.SetAddCallback(new AndroidIHdlInterface((isBool, adnroidActionDevSerial) =>
+                {
+                    if (isBool)
+                    {
 
+                        var list = VideDoorLockSend.Current.GetVideoDoorLockDeviceList(SPK.VideoDoorLock);
+                        if (list.Count > 0)
+                        {
+                            var function = list.Find((o) => o.sid == adnroidActionDevSerial);
+                            if (function != null)
+                            {
+                                this.SaveFunctionFile(function);
+                            }
+                        }
+
+
+                    }
+
+                }));
 #endif
+
+                    });
+
+
+            });
+
+
+
+
 
         }
         /// <summary>
@@ -63,35 +112,96 @@
         /// <param name="deviceSerial">璁惧搴忓垪鍙�</param>
         /// <param name="deviceId">璁惧id(浜戠涓奷eviceId)</param>
         /// <param name="spk">璁惧spk(浜戦泙涓婂畾涔夊ソ鐨�)</param>
-        public void SkipRTVActivity(string deviceSerial, string deviceId, string spk)
+        /// <param name="isDialog">鏄惁闇�瑕佸脊妗�</param>
+        public void SkipRTVActivity(string deviceSerial, string deviceId, string spk, bool isDialog)
         {
-            Video.View.ShowDialog.Currnet.ClickBox(Language.StringByID(StringId.laizimenlinghujiao), (dialog) =>
+
+            this.InitializationAndroidData((isBools) =>
             {
-                dialog.Close();
-            }, (dialog) =>
-            {
-                dialog.Close();
-            });
+                if (!isBools)
+                {
+                    this.MainThread(() =>
+                    {
+                        this.ShowTip("鍏堣幏鍙栬悿鐭充簯瀛愯处鍙穞oken澶辫触銆�");
+
+                    });
+                }
+
+                if (isDialog)
+                {
+                    Video.View.ShowDialog.Currnet.ClickBox(Language.StringByID(StringId.laizimenlinghujiao), (dialog) =>
+                    {
+                        dialog.Close();
 #if __IOS__
+                        //鎵撳紑钀ょ煶瑙嗛鐣岄潰
+                        EZSDK.IOS.EZSDK.SharedInstance().PlayWithDeviceSerial(deviceSerial, deviceId, spk);
 #else
+                    HDLEzvizSdk.Instance.JumpToEZRealPlayActivity(Application.Activity,deviceId,deviceSerial,spk);
 #endif
-            //jumpToEZRealPlayActivity(Shared.Application.Activity,  deviceId,  deviceSerial,  spk)
+                    }, (dialog) =>
+                    {
+                        dialog.Close();
+                    });
+                }
+                else
+                {
+#if __IOS__
+                    //鎵撳紑钀ょ煶瑙嗛鐣岄潰
+                    EZSDK.IOS.EZSDK.SharedInstance().PlayWithDeviceSerial(deviceSerial, deviceId, spk);
+
+#else
+                    HDLEzvizSdk.Instance.JumpToEZRealPlayActivity(Application.Activity,deviceId,deviceSerial,spk);
+#endif
+                }
+
+
+            });
+
+
+
         }
         /// <summary>
         /// 娴忚鍘嗗彶璁板綍
         /// </summary>
-        public void SkipRecordActivity()
+        public void SkipRecordActivity(string deviceId)
         {
-            //鏈疄鐜�
-            //this.InitializationAndroidData();
-            //
+            this.InitializationAndroidData((s) =>
+            {
+
+#if __IOS__
+                //鎵撳紑钀ょ煶鍘嗗彶璁板綍鐣岄潰
+                EZSDK.IOS.EZSDK.SharedInstance().ToDeviceMsgListView(deviceId);
+#else
+                HDLEzvizSdk.Instance.JumpLockHistoryActivity(Application.Activity, deviceId);
+#endif
+
+            });
+            
         }
         /// <summary>
         /// 涓存椂瀵嗙爜寮�闂�
+        /// <paramref name="deviceId"/>
         /// </summary>
-        public void SkipPSWActivity()
+        public void SkipPSWActivity(string deviceId)
         {
-            //jumpTempPasswordActivity(Application.Activity, deviceId);
+            this.InitializationAndroidData((isBools) =>
+            {
+                if (!isBools)
+                {
+                    this.MainThread(() =>
+                    {
+                        this.ShowTip("鍏堣幏鍙栬悿鐭充簯瀛愯处鍙穞oken澶辫触銆�");
+
+                    });
+                }
+#if __IOS__
+                //鎵撳紑钀ょ煶涓存椂瀵嗙爜鐣岄潰
+                EZSDK.IOS.EZSDK.SharedInstance().ToTemPassView(deviceId);
+#else
+                HDLEzvizSdk.Instance.JumpTempPasswordActivity(Application.Activity, deviceId); 
+#endif
+
+            });
         }
 
         /// <summary>
@@ -99,6 +209,8 @@
         /// </summary>
         public void InitializationAndroidData(Action<bool> action)
         {
+
+
             bool isBool = true;
             this.SunThread(() =>
             {
@@ -117,50 +229,22 @@
                         Application.RunOnMainThread(() =>
                         {
 #if __IOS__
-                                //iOS
-                                //鍒濆鍖栬悿鐭充簯SDK锛屼腑鏂囧浗鍐卥ey銆佽嫳鏂囨捣澶杒ey 寮�鍙戣�呰处鍙蜂娇鐢ㄥ簲鐢ㄥ寘鍚嶇敵璇风殑APPKEY锛屼笉鍚屽寘鍚嶅簲鐢ㄩ渶閰嶇疆涓嶅悓鐨凙PPKEY
-                                EZSDK.IOS.EZSDK.SharedInstance().InitLibWithAppKey("1aa98a90489b4838b966b57018b4b04b", "1aa98a90489b4838b966b57018b4b04b");
-                                //1.璁剧疆鎵�闇�娌充笢鐨凙ccessToken鍜孯efreshToken銆佸煙鍚嶅湴鍧�
-                                EZSDK.IOS.EZSDK.SharedInstance().SetHDlAccessToken(UserVideoDoorLockInfo.Current.LoginTokenString, UserVideoDoorLockInfo.Current.RefreshToken);
-                                EZSDK.IOS.EZSDK.SharedInstance().SetRequestHttpsHostAndPlatform(OnAppConfig.Instance.RequestHttpsHost, 1, DB_ResidenceData.Instance.CurrentRegion.id);
-                                //2.璁剧疆钀ょ煶瀛愯处鍙风殑AccessToken鍒癝DK
-                                EZSDK.IOS.EZSDK.SharedInstance().SetEZAccessToken(ezChildAccessToken);
-                                ////3.鎵撳紑鎽勫儚澶磋澶囧垪琛ㄩ〉闈�
-                                EZSDK.IOS.EZSDK.SharedInstance().Go2EZvizMonitor();
-                                //EZSDK.IOS.EZDeviceInfo info = new EZSDK.IOS.EZDeviceInfo();
-                                //info.de
-                                //EZSDK.IOS.EZSDK.Play(info);
+                            //iOS
+                            //鍒濆鍖栬悿鐭充簯SDK锛屼腑鏂囧浗鍐卥ey銆佽嫳鏂囨捣澶杒ey 寮�鍙戣�呰处鍙蜂娇鐢ㄥ簲鐢ㄥ寘鍚嶇敵璇风殑APPKEY锛屼笉鍚屽寘鍚嶅簲鐢ㄩ渶閰嶇疆涓嶅悓鐨凙PPKEY
+                            EZSDK.IOS.EZSDK.SharedInstance().InitLibWithAppKey("1aa98a90489b4838b966b57018b4b04b", "1aa98a90489b4838b966b57018b4b04b");
+                            //1.璁剧疆鎵�闇�娌充笢鐨凙ccessToken鍜孯efreshToken銆佸煙鍚嶅湴鍧�
+                            EZSDK.IOS.EZSDK.SharedInstance().SetHDlAccessToken(UserInfo.Current.LoginTokenString, UserInfo.Current.RefreshToken);
+                            EZSDK.IOS.EZSDK.SharedInstance().SetRequestHttpsHostAndPlatform(OnAppConfig.Instance.RequestHttpsHost, 1, DB_ResidenceData.Instance.CurrentRegion.id);
+                            //2.璁剧疆钀ょ煶瀛愯处鍙风殑AccessToken鍒癝DK
+                            EZSDK.IOS.EZSDK.SharedInstance().SetEZAccessToken(ezChildAccessToken);
+                            //////3.鎵撳紑鎽勫儚澶磋澶囧垪琛ㄩ〉闈�
+                            //EZSDK.IOS.EZSDK.SharedInstance().Go2EZvizMonitor();
+                            //EZSDK.IOS.EZDeviceInfo info = new EZSDK.IOS.EZDeviceInfo();
+                            //info.de
+                            //EZSDK.IOS.EZSDK.Play(info);
 #else
-                            //Android
-                            //1.璁剧疆鎵�闇�娌充笢鐨則oken銆佸煙鍚嶅湴鍧�
-                            //2.璁剧疆钀ょ煶瀛愯处鍙风殑token
-                            //3.鎵撳紑鎽勫儚澶磋澶囧垪琛ㄩ〉闈�
-                            ((BaseActivity)Shared.Application.Activity).SetCamera(b =>
-                            {
-                                if (b)
-                                {
-                                    ((BaseActivity)Shared.Application.Activity).SetPermission(result =>
-                                    {
-                                        if (result)
-                                        {
-                                            Android.Content.Intent intent = new Android.Content.Intent();
-                                            var bundle = new Android.OS.Bundle();
-                                            //浼犻�抧ame鍙傛暟涓簍inyphp
-                                            bundle.PutString("EzChildAccessToken", ezChildAccessToken);
-                                            bundle.PutString("HdlToken", UserInfo.Current.LoginTokenString);
-                                            bundle.PutString("HdlrefreshToken", UserInfo.Current.RefreshToken);
-                                            bundle.PutString("Url", OnAppConfig.Instance.RequestHttpsHost);
-                                            bundle.PutString("EzvizAppKey", "1aa98a90489b4838b966b57018b4b04b");
-                                            bundle.PutInt("Platform", 1);
-                                            bundle.PutString("HomeId", DB_ResidenceData.Instance.CurrentRegion.id);
-                                            intent.PutExtras(bundle);
-                                            //intent.SetComponent(new Android.Content.ComponentName(Shared.Application.Activity, "com.videogo.MainActivity"));
-                                            //Shared.Application.Activity.StartActivity(intent);
-                                        }
-                                    }, "android.permission.RECORD_AUDIO");
+                            HDLEzvizSdk.Instance.Init(Application.Activity.Application, ezChildAccessToken, UserInfo.Current.LoginTokenString, UserInfo.Current.RefreshToken, OnAppConfig.Instance.RequestHttpsHost, "1aa98a90489b4838b966b57018b4b04b", 1, DB_ResidenceData.Instance.CurrentRegion.id);
 
-                                }
-                            });
 #endif
                         });
 
@@ -179,33 +263,33 @@
                 }
             });
         }
+
         /// <summary>
         /// 鏇存崲浣忓畢
         /// </summary>
         /// <param name="home">瀵硅薄</param>
         public void ChangeCurrHome(RegionInfoRes home)
         {
+            
             if (DB_ResidenceData.Instance.CurrentRegion.id == home.id || string.IsNullOrEmpty(home.id)) return;
+#if __IOS__
+#else
+                HDLEzvizSdk.Instance.SetHomeId(home.id);
+#endif
 
         }
         #endregion
 
         /// <summary>
-        /// 钀ょ煶瑙嗛闂ㄩ攣鐨勫浘鏍�
-        /// <param name="comerom">鏉ヨ嚜閭i噷</param>
+        /// 鑾峰彇闂ㄩ攣鍨嬪彿鍒楄〃
         /// </summary>
-        public string GetVideoDoorLockIcon(Comerom comerom)
+        /// <returns>杩斿洖缁撴灉涓嶄細涓簄ull</returns>
+        public List<string> GetVideoDoorLockLockModelsList()
         {
-            if (comerom == Comerom.collect)
-            {
-                return "FunctionIcon/DoorLock/VideoDoorLockOpen.png";
-            }
-            else
-            {
-                return "FunctionIcon/DoorLock/VideoDoorlockClose.png";
-            }
-
+            return VideDoorLockSend.Current.GetVideoDoorLockLockModelsList();
         }
+
+
         #region  --------- 鍔熻兘鏂囦欢淇濆瓨锛屽垹闄� --------
         /// <summary>
         /// 淇濆瓨鏈湴鏂囦欢
@@ -232,6 +316,23 @@
         }
         #endregion
         /// <summary>
+        /// 钀ょ煶瑙嗛闂ㄩ攣鐨勫浘鏍�
+        /// <param name="comerom">鏉ヨ嚜閭i噷</param>
+        /// </summary>
+        public string GetVideoDoorLockIcon(Comerom comerom)
+        {
+            if (comerom == Comerom.collect)
+            {
+                return "FunctionIcon/DoorLock/VideoDoorLockOpen.png";
+            }
+            else
+            {
+                return "FunctionIcon/DoorLock/VideoDoorlockClose.png";
+            }
+
+        }
+       
+        /// <summary>
         /// 鑾峰彇Loading瀵硅薄
         /// </summary>
         /// <returns></returns>
@@ -239,27 +340,31 @@
         {
             get
             {
-                if (loading == null)
+                this.MainThread(() =>
                 {
-                    loading = new Loading();
-                }
-                if (MainPage.BasePageView.ChildrenCount < 1)
-                {
-                    return loading;
-                }
-                View view = MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1);
-                if (view is FrameLayout)
-                {
-                    ((FrameLayout)view).AddChidren(loading);
-                }
-                else if (view is PageLayout)
-                {
-                    ((PageLayout)view).AddChidren(loading);
-                }
+                    //if (loading != null && this.pageLayoutIndexValue == MainPage.BasePageView.ChildrenCount - 1)
+                    //{
+                    //    //闃叉浜岄噸娣诲姞瀵硅薄
+                    //    return;
+                    //}
+                    if (loading == null)//|| MainPage.BasePageView.ChildrenCount < 1)
+                    {
+                        loading = new Loading();
+                    }
+                    //loading.BringToFront();
+                    Application.MainPage.AddChidren(loading);
+                    //View view = MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1);
+                    //if (view is ViewGroup)
+                    //{
+                    //    pageLayoutIndexValue = MainPage.BasePageView.ChildrenCount - 1;
+                    //    ((ViewGroup)view).AddChidren(loading);
+                    //}
+                });
                 return loading;
             }
 
         }
+
         /// <summary>
         /// 鑾峰彇钀ょ煶瑙嗛闂ㄩ攣鍒楄〃
         /// </summary>
@@ -376,5 +481,57 @@
             room,//鎴块棿
             push,//鎺ㄩ��
         }
+
+#if __IOS__
+        IosIHdlInterface ezsdkDelegate;
+        /// <summary>
+        /// 涓撻棬瀹氫箟缁橧os鍥炶皟鐢ㄧ潃,娌℃湁鐗规畩鍚箟
+        /// </summary>
+        public class IosIHdlInterface : EZSDK.IOS.EZSDKDelegate
+        {
+          public  Action<string> mAction;
+            public IosIHdlInterface()
+            {
+             
+            }
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="p0">true鏄叆缃戞垚鍔�(婧愮敓鍥炶皟杩斿洖)</param>
+            /// <param name="p1">璁惧鐨勫簭鍒楀寲(婧愮敓鍥炶皟杩斿洖)</param>
+            public override void AddDeviceSuccessed(string deviceSerial)
+            {
+                mAction?.Invoke(deviceSerial);
+            }
+        }
+#else
+        /// <summary>
+        /// 涓撻棬瀹氫箟缁欏畨鍗撳洖璋冪敤鐫�,娌℃湁鐗规畩鍚箟
+        /// </summary>
+        public class AndroidIHdlInterface : Java.Lang.Object, IHdlInterface
+        {
+
+            Action<bool,string> mAction;
+            public AndroidIHdlInterface(Action<bool,string> action)
+            {
+                mAction = action;
+            }
+            /// <summary>
+            /// 
+            /// </summary>
+            /// <param name="p0">true鏄叆缃戞垚鍔�(婧愮敓鍥炶皟杩斿洖)</param>
+            /// <param name="p1">璁惧鐨勫簭鍒楀寲(婧愮敓鍥炶皟杩斿洖)</param>
+            public void AddCallback(bool p0, string p1)
+            {
+                mAction?.Invoke(p0,p1);
+            }
+
+           
+        }
+#endif
+
+
     }
+
+
 }

--
Gitblit v1.8.0