From 372ebbd137d2951a7ac03b964d530d05ad7a5971 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 15 三月 2023 18:17:04 +0800
Subject: [PATCH] 2023年03月15日18:16:54

---
 HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs |  295 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 287 insertions(+), 8 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs
index ac956de..f07cff2 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs
@@ -1,15 +1,16 @@
 锘縰sing System;
 using HDL_ON.Entity;
 using System.Collections.Generic;
+using Shared;
 
 namespace HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock
 {
+    /// <summary>
+    /// 钀ょ煶瑙嗛闂ㄩ攣鍏叡鏂规硶绫�
+    /// </summary>
     public class CommonMethod
     {
-        public CommonMethod()
-        {
-        }
-
+        private Loading loading;
         private static CommonMethod commonMethod = null;
 
         public static CommonMethod Current
@@ -26,15 +27,172 @@
             }
 
         }
+
+        #region  --------- 璺宠浆鍒癆ndroid閭h竟鐨勬柟娉�(钀ょ煶瑙嗛闂ㄩ攣) --------
         /// <summary>
-        /// 璺宠浆鍒癆ndroid閭h竟鍘�
+        /// 娣诲姞璁惧鍒颁簯绔�
+        /// <paramref name="devSerial"/>璁惧搴忓垪鍙�</param>
         /// </summary>
-        public void SkipActivity()
+        public void SkipAddDeviceActivity(string devSerial)
         {
+            if (string.IsNullOrEmpty(devSerial)) return;
+            new System.Threading.Thread(() =>
+            {
+                var list = VideDoorLockSend.Current.GetVideoDoorLockDeviceList(SPK.VideoDoorLock);
+                if (list.Count > 0)
+                {
+                    var function = list.Find((o) => o.sid == devSerial);
+                    if (function != null)
+                    {
+                        this.SaveFunctionFile(function);
+                    }
+                }
+            })
+            { IsBackground = true }.Start();
             //鏈疄鐜�
+#if __IOS__
+
+#else
+
+#endif
+
         }
         /// <summary>
+        /// 鎵撳紑瀹炴椂瑙嗛鐢婚潰
+        /// </summary>
+        /// <param name="deviceSerial">璁惧搴忓垪鍙�</param>
+        /// <param name="deviceId">璁惧id(浜戠涓奷eviceId)</param>
+        /// <param name="spk">璁惧spk(浜戦泙涓婂畾涔夊ソ鐨�)</param>
+        public void SkipRTVActivity(string deviceSerial, string deviceId, string spk)
+        {
+            Video.View.ShowDialog.Currnet.ClickBox(Language.StringByID(StringId.laizimenlinghujiao), (dialog) =>
+            {
+                dialog.Close();
+            }, (dialog) =>
+            {
+                dialog.Close();
+            });
+#if __IOS__
+#else
+#endif
+            //jumpToEZRealPlayActivity(Shared.Application.Activity,  deviceId,  deviceSerial,  spk)
+        }
+        /// <summary>
+        /// 娴忚鍘嗗彶璁板綍
+        /// </summary>
+        public void SkipRecordActivity()
+        {
+            //鏈疄鐜�
+            //this.InitializationAndroidData();
+            //
+        }
+        /// <summary>
+        /// 涓存椂瀵嗙爜寮�闂�
+        /// </summary>
+        public void SkipPSWActivity()
+        {
+            //jumpTempPasswordActivity(Application.Activity, deviceId);
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栬悿鐭砈DK(瀹為檯灏辨槸浼犲弬鏁�,澶氭璋冪敤涔熸病鏈夊奖鍝�)
+        /// </summary>
+        public void InitializationAndroidData(Action<bool> action)
+        {
+            bool isBool = true;
+            this.SunThread(() =>
+            {
+                try
+                {
+                    //鍏堣幏鍙栬悿鐭充簯瀛愯处鍙穞oken
+                    var ezChildAccessToken = VideDoorLockSend.Current.GetEZGetChildToken();
+                    this.MainThread(() =>
+                    {
+                        if (string.IsNullOrEmpty(ezChildAccessToken))
+                        {
+                            //Token
+                            isBool = false;
+                            return;
+                        }
+                        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);
+#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");
+
+                                }
+                            });
+#endif
+                        });
+
+                    });
+
+                }
+                catch (Exception e)
+                {
+                }
+                finally
+                {
+                    this.MainThread(() =>
+                    {
+                        action?.Invoke(isBool);
+                    });
+                }
+            });
+        }
+        /// <summary>
+        /// 鏇存崲浣忓畢
+        /// </summary>
+        /// <param name="home">瀵硅薄</param>
+        public void ChangeCurrHome(RegionInfoRes home)
+        {
+            if (DB_ResidenceData.Instance.CurrentRegion.id == home.id || string.IsNullOrEmpty(home.id)) return;
+
+        }
+        #endregion
+
+        /// <summary>
         /// 钀ょ煶瑙嗛闂ㄩ攣鐨勫浘鏍�
+        /// <param name="comerom">鏉ヨ嚜閭i噷</param>
         /// </summary>
         public string GetVideoDoorLockIcon(Comerom comerom)
         {
@@ -48,6 +206,7 @@
             }
 
         }
+        #region  --------- 鍔熻兘鏂囦欢淇濆瓨锛屽垹闄� --------
         /// <summary>
         /// 淇濆瓨鏈湴鏂囦欢
         /// </summary>
@@ -71,9 +230,36 @@
             FunctionList.List.DeleteFunction(function);
             MainPage.Log($"鏂囦欢鍒犻櫎->{function.name}-->{function.spk}");
         }
+        #endregion
+        /// <summary>
+        /// 鑾峰彇Loading瀵硅薄
+        /// </summary>
+        /// <returns></returns>
+        public Loading Loading
+        {
+            get
+            {
+                if (loading == null)
+                {
+                    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);
+                }
+                return loading;
+            }
 
-
-
+        }
         /// <summary>
         /// 鑾峰彇钀ょ煶瑙嗛闂ㄩ攣鍒楄〃
         /// </summary>
@@ -87,7 +273,90 @@
 #endif
             return list;
         }
+        #region  ---------鑷畾涔夌嚎绋�(瀛愮嚎绋嬶紝涓荤嚎绋�)--------
+        /// <summary>
+        /// 瀛愮嚎绋�
+        /// </summary>
+        /// <paramref name="tipType"/>鏄惁瑕佹彁绀洪敊璇俊鎭�(榛樿鏄剧ず)<paramref>
+        /// <param name="action"></param>
+        public void SunThread(Action action, TipType tipType = TipType.confirmation)
+        {
+            new System.Threading.Thread(() =>
+            {
+                try
+                {
+                    action?.Invoke();
+                }
+                catch (Exception e)
+                {
+                    this.ShowAlert(e, tipType);
+                }
+            })
+            { IsBackground = true }.Start();
 
+        }
+        /// <summary>
+        /// 涓荤嚎绋�(UI鏇存柊)
+        /// </summary>
+        /// <paramref name="tipType"/>鏄惁瑕佹彁绀洪敊璇俊鎭�(榛樿鏄剧ず)<paramref>
+        /// <param name="action"></param>
+        public void MainThread(Action action, TipType tipType = TipType.confirmation)
+        {
+            Application.RunOnMainThread(() =>
+            {
+                try
+                {
+                    action?.Invoke();
+                }
+                catch (Exception e)
+                {
+                    this.ShowAlert(e, tipType);
+                }
+            });
+
+        }
+        #endregion
+        #region  --------- 鎻愮ず妗嗭紝纭妗� --------
+        /// <summary>
+        /// 瀵硅瘽妗�(鍙绋嬪簭鎶ラ敊鐨勬椂鍊欐墠鐢ㄥ埌)
+        /// </summary>
+        /// <paramref name="e"/>寮傚父瀵硅薄<paramref>
+        /// <paramref name="tipType"/>鏄惁瑕佹彁绀洪敊璇俊鎭�(榛樿鏄剧ず)<paramref>
+        private void ShowAlert(Exception e, TipType tipType)
+        {
+
+            if (tipType != TipType.confirmation)
+            {
+                return;
+            }
+            Application.RunOnMainThread(() =>
+            {
+                string msg = e.Message + "\r\n" + e.StackTrace;
+                Alert alert = new Alert("鎶辨瓑绋嬪簭鍑洪敊浜�.", "鎸塡"纭畾\"鑳借幏鍙栨洿璇︾粏鐨勯敊璇俊鎭�.", "鍙栨秷", "纭畾");
+                alert.Show();
+                alert.ResultEventHandler += (alerts, isBool) =>
+                {
+                    alert.Dismiss();
+                    if (isBool)
+                    {
+                        StackTraceLog stackTraceLog = new StackTraceLog(msg);
+                        stackTraceLog.Show();
+                    }
+                };
+            });
+        }
+        /// <summary>
+        /// 淇℃伅鎻愮ず绐楀彛锛岃嚜鍔ㄥ叧闂�
+        /// </summary>
+        /// <param name="msg">鎻愮ず閿欒鏂囨湰</param>
+        public void ShowTip(string msg, int time = 2)
+        {
+            Application.RunOnMainThread(() =>
+            {
+                new PublicAssmebly().TipMsgAutoClose(msg, false, time * 1000);
+            });
+        }
+        #endregion
         /// <summary>
         /// 寮规绫诲瀷
         /// </summary>
@@ -97,5 +366,15 @@
             flicker,//闂儊妗�
             confirmation//纭妗�
         }
+        /// <summary>
+        /// 琛ㄧず鏉ヨ嚜閭d釜鐣岄潰
+        /// </summary>
+        public enum Comerom
+        {
+            function,//鍔熻兘
+            collect,//鏀惰棌
+            room,//鎴块棿
+            push,//鎺ㄩ��
+        }
     }
 }

--
Gitblit v1.8.0