From f46be160caed45c67e8980173d29ed48d525a4d3 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期二, 28 三月 2023 14:49:52 +0800 Subject: [PATCH] 2023年03月28日14:49:50 --- HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs | 370 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 362 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..ccca825 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/CommonMethod.cs @@ -1,17 +1,29 @@ 锘縰sing System; 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 { + /// <summary> + /// 钀ょ煶瑙嗛闂ㄩ攣鍏叡鏂规硶绫� + /// </summary> public class CommonMethod { - public CommonMethod() - { - } + private Loading loading; + /// <summary> + /// 璁板綍褰撳墠鐣岄潰绱㈠紩鍊� + /// </summary> + private int pageLayoutIndexValue; private static CommonMethod commonMethod = null; - + /// <summary> + /// 鑾峰彇瀵硅薄 + /// </summary> public static CommonMethod Current { get @@ -26,15 +38,201 @@ } } + +#region --------- 璺宠浆鍒癆ndroid閭h竟鐨勬柟娉�(钀ょ煶瑙嗛闂ㄩ攣) -------- /// <summary> - /// 璺宠浆鍒癆ndroid閭h竟鍘� + /// 璇诲彇浜戠鐨勪笂璁惧鍒楄〃(android婧愮敓娣诲姞璁惧鍒颁簯绔垚鍔熷悗) + /// <paramref name="devSerial"/>璁惧搴忓垪鍙�</param> /// </summary> - public void SkipActivity() + public void SkipAddDeviceActivity(string spk) { - //鏈疄鐜� +#if __IOS__ + +#else + this.InitializationAndroidData((isBools) => + { + if (!isBools) { + this.MainThread(()=> { + this.ShowTip("鍏堣幏鍙栬悿鐭充簯瀛愯处鍙穞oken澶辫触銆�"); + + }); + } + 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> + /// 鎵撳紑瀹炴椂瑙嗛鐢婚潰 + /// </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) + { +#if __IOS__ +#else + this.InitializationAndroidData((isBools) => + { + if (!isBools) + { + this.MainThread(() => { + this.ShowTip("鍏堣幏鍙栬悿鐭充簯瀛愯处鍙穞oken澶辫触銆�"); + + }); + } + Video.View.ShowDialog.Currnet.ClickBox(Language.StringByID(StringId.laizimenlinghujiao), (dialog) => + { + dialog.Close(); + HDLEzvizSdk.Instance.JumpToEZRealPlayActivity(Application.Activity,deviceId,deviceSerial,spk); + }, (dialog) => + { + dialog.Close(); + }); + + }); + + +#endif + } + /// <summary> + /// 娴忚鍘嗗彶璁板綍 + /// </summary> + public void SkipRecordActivity(string deviceId) + { + this.InitializationAndroidData((s)=> { + +#if __IOS__ +#else + HDLEzvizSdk.Instance.JumpLockHistoryActivity(Application.Activity, deviceId); +#endif + + }); + //鏈疄鐜� + //this.InitializationAndroidData(); + // + } + /// <summary> + /// 涓存椂瀵嗙爜寮�闂� + /// <paramref name="deviceId"/> + /// </summary> + public void SkipPSWActivity(string deviceId) + { + + this.InitializationAndroidData((isBools) => + { + if (!isBools) + { + this.MainThread(() => + { + this.ShowTip("鍏堣幏鍙栬悿鐭充簯瀛愯处鍙穞oken澶辫触銆�"); + + }); + } +#if __IOS__ +#else + HDLEzvizSdk.Instance.JumpTempPasswordActivity(Application.Activity, deviceId); +#endif + + }); + } + + /// <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(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 + HDLEzvizSdk.Instance.Init(Application.Activity.Application, ezChildAccessToken, UserInfo.Current.LoginTokenString, UserInfo.Current.RefreshToken, OnAppConfig.Instance.RequestHttpsHost, "1aa98a90489b4838b966b57018b4b04b", 1, DB_ResidenceData.Instance.CurrentRegion.id); + +#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 +246,7 @@ } } +#region --------- 鍔熻兘鏂囦欢淇濆瓨锛屽垹闄� -------- /// <summary> /// 淇濆瓨鏈湴鏂囦欢 /// </summary> @@ -71,8 +270,39 @@ FunctionList.List.DeleteFunction(function); MainPage.Log($"鏂囦欢鍒犻櫎->{function.name}-->{function.spk}"); } +#endregion + /// <summary> + /// 鑾峰彇Loading瀵硅薄 + /// </summary> + /// <returns></returns> + public Loading Loading + { + get + { + this.MainThread(() => + { + //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> /// 鑾峰彇钀ょ煶瑙嗛闂ㄩ攣鍒楄〃 @@ -87,7 +317,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 +410,46 @@ flicker,//闂儊妗� confirmation//纭妗� } + /// <summary> + /// 琛ㄧず鏉ヨ嚜閭d釜鐣岄潰 + /// </summary> + public enum Comerom + { + function,//鍔熻兘 + collect,//鏀惰棌 + room,//鎴块棿 + push,//鎺ㄩ�� + } + +#if __IOS__ +#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