From adc150efb13a0506f45a3c344c3ee2ef2dba8e90 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 01 七月 2021 15:19:13 +0800
Subject: [PATCH] 合并嘉乐lc代码

---
 HDL-ON_Android/LeChengVideo/Form/ReverseCallFragment.cs |  317 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 317 insertions(+), 0 deletions(-)

diff --git a/HDL-ON_Android/LeChengVideo/Form/ReverseCallFragment.cs b/HDL-ON_Android/LeChengVideo/Form/ReverseCallFragment.cs
new file mode 100644
index 0000000..84d67cf
--- /dev/null
+++ b/HDL-ON_Android/LeChengVideo/Form/ReverseCallFragment.cs
@@ -0,0 +1,317 @@
+锘�
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Android.App;
+using Android.Icu.Text;
+using Android.OS;
+using Android.Runtime;
+using Android.Util;
+using Android.Views;
+using Android.Widget;
+using HDL_ON.Common;
+using HDL_ON.DAL.Server;
+using Java.Util;
+
+namespace HDL_ON_Android.LeChengView.Form
+{
+    public class ReverseCallFragment : Fragment, View.IOnClickListener
+    {
+
+        private View mView;
+
+        private ImageView screenshotImg;// 鎴浘
+        private ImageView unlockImg;// 寮�閿�
+        private LinearLayout answerLayout; // 鎺ュ惉
+        private ImageView hangupImg;// 鎸傛柇
+        private ImageView answerImg;// 鎺ュ惉
+        private TextView hangupText;
+
+        private TextView tvTip;
+
+        private System.Threading.Timer timer = null;
+        private int Time = 0;
+
+        private static LeChengVideoActivity CurtActivity;
+
+        public override void OnCreate(Bundle savedInstanceState)
+        {
+            base.OnCreate(savedInstanceState);
+
+            CurtActivity = (LeChengVideoActivity)this.Activity;
+        }
+
+        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+        {
+            mView = inflater.Inflate(Resource.Layout.fragment_call, container, false);
+
+            IniView();
+
+            CurtActivity.Play();
+
+            CurtActivity.CloseAudio();
+            
+            return mView;
+        }
+
+        private void IniView()
+        {
+            screenshotImg = (ImageView)mView.FindViewById(Resource.Id.callScreenshotImg);//
+            unlockImg = (ImageView)mView.FindViewById(Resource.Id.callUnlockImg);//
+            tvTip = (TextView)mView.FindViewById(Resource.Id.callTipText);
+            answerLayout = (LinearLayout)mView.FindViewById(Resource.Id.callAnswerLayout);
+            hangupImg = (ImageView)mView.FindViewById(Resource.Id.callHangupImg);
+            answerImg = (ImageView)mView.FindViewById(Resource.Id.callAnswerImg);
+            hangupText = (TextView)mView.FindViewById(Resource.Id.callHangupText);
+
+            screenshotImg.SetOnClickListener(this);
+            unlockImg.SetOnClickListener(this);
+            hangupImg.SetOnClickListener(this);
+            answerImg.SetOnClickListener(this);
+
+            hangupText.SetText(GetString(Resource.String.video_not_answer), null);
+            tvTip.SetText(GetString(Resource.String.calling), null);
+        }
+
+
+        /// <summary>
+        /// 寮�閿�
+        /// </summary>
+        private void PostUnlock()
+        {
+            //寮�閿侊紝褰撴敹鍒版潵鐢典俊鎭椂鍙繘琛屽紑閿佹搷浣�
+            new Thread(() =>
+            {
+                try
+                {
+                    Dictionary<string, object> d = new Dictionary<string, object>();
+                    d.Add("deviceId", CurtActivity.DeviceId);//璁惧id
+                    string jsonString = HttpUtil.GetSignRequestJson(d);
+
+                    string url = "/home-wisdom/platform/imou/openDoorbell";
+                    ResponsePackNew response = HttpUtil.RequestHttpsPost(url, jsonString);
+                    Log.Info("LcVideo", "Post Unlock Response code=" + response.Code);
+                }
+                catch { }
+
+            }).Start();
+        }
+
+        /// <summary>
+        /// 鏇存柊寮�閿佹寜閽姸鎬�,寮�閿佹垚鍔燂紝15绉掑唴涓嶇粰鍐嶇偣鍑绘寜閽�
+        /// </summary>
+        private void UpdataUnlockState()
+        {
+            try
+            {
+                if (unlockImg == null) return;
+
+                unlockImg.Enabled = false;
+
+                new Thread(() =>
+                {
+                    Thread.Sleep(15 * 1000);
+                    Activity.RunOnUiThread(() =>
+                    {
+                        if (unlockImg != null)
+                            unlockImg.Enabled = true;
+                    });
+                }).Start();
+            }
+            catch { }
+        }
+
+        private string GetTime(int time)
+        {
+
+            int m = time / 60;
+            int s = time % 60;
+
+            return UnitFormat(m) + ":" + UnitFormat(s);
+
+        }
+
+        private static string UnitFormat(int i)
+        {
+            string retStr = null;
+            if (i >= 0 && i < 10)
+                retStr = "0" + i;
+            else
+                retStr = "" + i;
+            return retStr;
+        }
+
+        /// <summary>
+        /// 閫氳瘽璁板綍璁℃椂鍣紝浠庢媺娴佹垚鍔熷紑濮嬭绠楁椂闂�
+        /// </summary>
+        public void TimeStarts()
+        {
+            try
+            {
+                if (timer != null)
+                    timer.Dispose();
+
+                TimerCallback timerCallback = new TimerCallback(Tick);
+                timer = new System.Threading.Timer(timerCallback, null, 0, 1000);
+
+            }
+            catch (Exception) { }
+        }
+
+        public void TimeEnd()
+        {
+            Time = 0;
+
+            if (timer != null)
+            {
+                timer.Dispose();
+                timer = null;
+            }
+        }
+
+        public void Tick(object state)
+        {
+            try
+            {
+                Activity.RunOnUiThread(() =>
+                {
+                    try
+                    {
+                        Time++;
+                        if (tvTip != null)
+                            tvTip.SetText(GetTime(Time), null);
+                    }
+                    catch { }
+                });
+            }
+            catch { }
+        }
+
+        public void OnClick(View v)
+        {
+            if (v.Equals(answerImg))
+            {
+                //鎺ユ敹鏉ョ數
+                CurtActivity.StartTalk();
+                answerLayout.Visibility = ViewStates.Gone;
+                PostAnswer();
+            }
+            else if (v.Equals(hangupImg))
+            {
+                CurtActivity.StopTalk();
+                PostHangup();
+                TimeEnd();
+                Activity.Finish();
+            }
+            else if (v.Equals(screenshotImg))
+            {
+                //鏈夎棰戣繃鏉ュ彲璋冪敤姝ゆ帴鍙h繘琛屾媿鐓�
+            }
+            else if (v.Equals(unlockImg))
+            {
+                PostUnlock();
+            }
+        }
+
+        /// <summary>
+        /// post 鎴浘
+        /// </summary>
+        /// <param name="path">鎴浘淇濈暀鐨勮矾寰�</param>
+        private void PostScreenshot(string path)
+        {
+            new Thread(() =>
+            {
+                try
+                {
+                    string[] str = path.Split("/");
+                    string img_name = str.GetValue(str.Length - 1).ToString().Replace(".jpg", "");
+                    byte[] images = FileUtlis.Files.ReadFileForPath(path);
+                    Dictionary<string, object> d = new Dictionary<string, object>();
+                    d.Add("callId", VideoActivity.CallId);
+                    d.Add("images", images);
+                    d.Add("imagesName", img_name);
+                    string jsonString = HttpUtil.GetSignRequestJson(d);
+
+                    string url = "/home-wisdom/app/fl/vi/screenshot";
+                    ResponsePackNew response = HttpUtil.RequestHttpsPost(url, jsonString);
+                    Log.Info("LcVideo", "Post Screenshot Response code=" + response.Code);
+                }
+                catch { }
+
+            }).Start();
+        }
+
+        /// <summary>
+        /// post 鎺ュ惉鐢佃瘽璁板綍
+        /// </summary>
+        public void PostAnswer()
+        {
+            new Thread(() =>
+            {
+                try
+                {
+                    Dictionary<string, object> d = new Dictionary<string, object>();
+                    d.Add("callId", CurtActivity.CallId);//鍛煎彨id
+                    d.Add("callStatus", "RECEIVED");//鍙敤鍊�:MISSED,RECEIVED,REJECT
+                    // d.Add("callDuration", Time);//閫氳瘽鏃堕暱锛堢锛�
+                    d.Add("interphoneTypeEnum", "IMOUVISIAL");//鍙敤鍊�:FLVI,IMOUVISIAL
+                    string jsonString = HttpUtil.GetSignRequestJson(d);
+
+                    string url = "/home-wisdom/platform/imou/updateCallStatus";
+                    ResponsePackNew response = HttpUtil.RequestHttpsPost(url, jsonString);
+                    Log.Info("LcVideo", "Post Answer Response code=" + response.Code);
+                }
+                catch { }
+
+            }).Start();
+        }
+
+        /// <summary>
+        /// post 鎸傛柇鐢佃瘽璁板綍
+        /// </summary>
+        public void PostHangup()
+        {
+            new Thread(() =>
+            {
+                try
+                {
+                    Dictionary<string, object> d = new Dictionary<string, object>();
+                    d.Add("callId", CurtActivity.CallId);//鍛煎彨id
+                    //d.Add("callStatus", "REJECT");//鍙敤鍊�:MISSED,RECEIVED,REJECT
+                    d.Add("callDuration", Time);//閫氳瘽鏃堕暱锛堢锛�
+                    d.Add("interphoneTypeEnum", "IMOUVISIAL");//鍙敤鍊�:FLVI,IMOUVISIAL
+                    string jsonString = HttpUtil.GetSignRequestJson(d);
+
+                    string url = "/home-wisdom/platform/imou/updateCallStatus";
+                    ResponsePackNew response = HttpUtil.RequestHttpsPost(url, jsonString);
+                    Log.Info("LcVideo", "Post Hangup Response code=" + response.Code);
+                }
+                catch { }
+
+            }).Start();
+        }
+
+        /// <summary>
+        /// post 鎷掓帴璁板綍,浠呭彧鏈夊湪姝e父鎸傛柇鐘舵�佷笅鎵嶆彁浜ら�氳瘽鏃堕棿
+        /// </summary>
+        public void PostReject()
+        {
+            new Thread(() =>
+            {
+                try
+                {
+                    Dictionary<string, object> d = new Dictionary<string, object>();
+                    d.Add("callId", CurtActivity.CallId);//鍛煎彨id
+                    d.Add("callStatus", "REJECT");//鍙敤鍊�:MISSED,RECEIVED,REJECT
+                    string jsonString = HttpUtil.GetSignRequestJson(d);
+
+                    string url = "/home-wisdom/platform/imou/updateCallStatus";
+                    ResponsePackNew response = HttpUtil.RequestHttpsPost(url, jsonString);
+                    Log.Info("LcVideo", "Post Reject Response code=" + response.Code);
+                }
+                catch { }
+
+            }).Start();
+        }
+    }
+}

--
Gitblit v1.8.0