From 80faceb86399017851f9f72feaaef868a37ff23f Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期五, 26 三月 2021 10:50:35 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/lss' into temp-wxr --- HDL-ON_Android/FengLinVideo/Form/MonitorFragment.cs | 208 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 208 insertions(+), 0 deletions(-) diff --git a/HDL-ON_Android/FengLinVideo/Form/MonitorFragment.cs b/HDL-ON_Android/FengLinVideo/Form/MonitorFragment.cs new file mode 100644 index 0000000..983b35a --- /dev/null +++ b/HDL-ON_Android/FengLinVideo/Form/MonitorFragment.cs @@ -0,0 +1,208 @@ +锘� +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using Android.App; +using Android.Content; +using Android.Icu.Text; +using Android.OS; +using Android.Runtime; +using Android.Util; +using Android.Views; +using Android.Widget; +using Com.ETouchSky; +using Com.Tool; +using HDL_ON.DAL.Server; +using HDL_ON_Android.FengLinVideo.Interface; +using Java.Util; +using Org.Json; + +namespace HDL_ON_Android.FengLinVideo.Form +{ + public class MonitorFragment : Fragment, View.IOnClickListener, VideoState + { + + private View mView; + private VideoPhone mPhone; + + // 鎴浘 + private LinearLayout screenshotLayout; + private ImageView screenImage; + private TextView ScreenText; + + //寮�閿� + private LinearLayout unlockLayout; + private ImageView unlockImag; + private TextView unlockText; + + // 鏇存柊绾跨▼ + private Thread thread = null; + + public MonitorFragment(VideoPhone phone) + { + this.mPhone = phone; + } + + public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) + { + mView = inflater.Inflate(Resource.Layout.fragment_monitor, container, false); + + IniView(); + + return mView; + } + + private void IniView() + { + screenshotLayout = (LinearLayout)mView.FindViewById(Resource.Id.icon_sceenshotLayout); + screenImage = (ImageView)mView.FindViewById(Resource.Id.icon_sceenshotImg); + ScreenText = (TextView)mView.FindViewById(Resource.Id.icon_sceenshotText); + + unlockLayout = (LinearLayout)mView.FindViewById(Resource.Id.icon_unlockLayout); + unlockImag = (ImageView)mView.FindViewById(Resource.Id.icon_unlockImg); + unlockText = (TextView)mView.FindViewById(Resource.Id.icon_unlockText); + + unlockLayout.SetOnClickListener(this); + screenshotLayout.SetOnClickListener(this); + } + + /// <summary> + /// 寮�閿� + /// </summary> + private void Unlock() + { + if (mPhone != null) + { + try + { + unlockImag.Selected = true; + JSONObject ht = new JSONObject(); + ht.Put("command", "open");//鍥哄畾鍙傛暟 + ht.Put("room_id", 123); + ht.Put("devType", 7); + mPhone.SendCustomData(ht.ToString()); + } + catch { } + } + } + + /// <summary> + /// 鏇存柊寮�閿佹寜閽姸鎬� + /// </summary> + private void UpdataUnlockState() + { + try + { + //寮�閿佹垚鍔燂紝15绉掑唴涓嶇粰鍐嶇偣鍑绘寜閽� + unlockLayout.Enabled = false; + if (thread != null) + { + try + { + thread.Interrupt(); + } + catch { } + thread = null; + } + + thread = new Thread(() => + { + try + { + Thread.Sleep(15 * 1000); + + Activity.RunOnUiThread(() => + { + if (unlockLayout != null) + unlockLayout.Enabled = true; + }); + } + catch { } + }); + + thread.Start(); + } + catch { } + } + + public void OnClick(View v) + { + // + if (v.Equals(unlockLayout)) + { + if (mPhone != null) + Unlock(); + } + else if (v.Equals(screenshotLayout)) + { + + //鏈夎棰戣繃鏉ュ彲璋冪敤姝ゆ帴鍙h繘琛屾媿鐓� + if (mPhone != null) + { + // 鍐呴儴鍌ㄥ瓨/DCIM/Camera/.....jpg + screenImage.Selected = true; + SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); + string time = format.Format(new Date(SystemClock.CurrentThreadTimeMillis())); + string ss = Android.OS.Environment.ExternalStorageDirectory.Path + "/DCIM/Camera"; + string path = ss + "/" + time + ".jpg"; + mPhone.Snap(path); + } + } + } + + /// <summary> + /// 閫氳瘽鐘舵�佸洖璋冩柟娉� + /// </summary> + /// <param name="msg"></param> + public void OnPhoneEvent(string msg) + { + try + { + // + TextProtocol tp = new TextProtocol(); + tp.Parse(msg); + string event1 = tp.GetString("event"); + + switch (event1) + { + case "EVT_HangUp"://鎸傛柇 + Activity.Finish(); + break; + case "EVT_RECV_CUSTOM_DATA": + UpdataUnlockState(); + break; + case "EVT_SnapAck": + int error = tp.GetInt("error"); + string filePath = tp.GetString("filePath"); + if (error == 0) + { + screenImage.Selected = true; + } + else + { + screenImage.Selected = false; + } + break; + } + } + catch { } + } + + public override void OnDestroy() + { + base.OnDestroy(); + + if (thread != null) + { + try + { + thread.Interrupt(); + } + catch { } + thread = null; + } + } + } +} \ No newline at end of file -- Gitblit v1.8.0