From 652243206427f35a256400a149a1734085824cb9 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 02 九月 2020 17:35:03 +0800 Subject: [PATCH] 2020-09-02-4 --- ZigbeeApp/GateWay.Droid/VideoActivity.cs | 62 ++++++++++++++++++++----------- 1 files changed, 40 insertions(+), 22 deletions(-) diff --git a/ZigbeeApp/GateWay.Droid/VideoActivity.cs b/ZigbeeApp/GateWay.Droid/VideoActivity.cs old mode 100644 new mode 100755 index a24392e..acf8255 --- a/ZigbeeApp/GateWay.Droid/VideoActivity.cs +++ b/ZigbeeApp/GateWay.Droid/VideoActivity.cs @@ -1,6 +1,7 @@ 锘縰sing System; using Android.App; using Android.Content.PM; +using System.Threading; using Android.Content.Res; using Android.Graphics; using Android.OS; @@ -20,6 +21,7 @@ [Activity(Name = "com.hdl.home.wxapi.VideoActivity", WindowSoftInputMode = SoftInput.AdjustResize, LaunchMode = LaunchMode.SingleInstance, ConfigurationChanges = (ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.LayoutDirection | ConfigChanges.Locale | ConfigChanges.Orientation | ConfigChanges.ScreenSize), Theme = "@style/MyTheme", ScreenOrientation = ScreenOrientation.Portrait)] public class VideoActivity : Android.App.Activity, View.IOnClickListener, ISurfaceHolderCallback, VideoPhoneJni.ICallBack,TipDiaglog.OnConfirmClickListener { + private static Activity activity; private VideoPhone mPhone; private ISurfaceHolder mRemoteSurfaceHolder; private FrameLayout mRemoteFrameContainer; @@ -36,8 +38,7 @@ public string DeviceName;//瀹ゅ鏈虹殑鍚嶇О锛屼緥锛屽澶栨満 public string RoomName;//鎴块棿鍛藉悕锛屼緥 8鏍�1鍗曞厓0801 public bool IsCollect;//鏄惁鏀惰棌 - public int Tpye = 0;//绫诲瀷锛�0 鐩戞帶锛�1鍙嶅懠 - + public int Tpye = 0;//绫诲瀷锛�0 鐩戞帶锛�1鍙嶅懠 protected override void OnCreate(Bundle savedInstanceState) { @@ -45,7 +46,7 @@ try { - + activity = this; ESVideoUUID = Intent.GetStringExtra("ESVideoUUID");//瀹ゅ鏈篣UID锛屼緥:JJY000007FSEYX ESRoomID = Intent.GetIntExtra("ESRoomID", 0);//褰撳墠鐢ㄦ埛鐨勬埧闂� ID 101 DeviceName = Intent.GetStringExtra("DeviceName");//瀹ゅ鏈虹殑鍚嶇О锛屼緥锛屽澶栨満 @@ -66,7 +67,8 @@ } else { - reverseCallFragment = new ReverseCallFragment(mPhone, ESVideoUUID); + string param = "address=" + ESVideoUUID + ",tag=mobile://123,"; + reverseCallFragment = new ReverseCallFragment(mPhone, param); FragmentManager.BeginTransaction().Replace(Resource.Id.content, reverseCallFragment).Commit(); } } @@ -148,7 +150,7 @@ base.OnPause(); if (mPhone != null) { - mPhone.OnActivityPause(); + //mPhone.OnActivityPause(); } } @@ -156,16 +158,30 @@ { base.OnDestroy(); if (mPhone != null) - { - mPhone.OnActivityDestroy(); + { + mPhone.HangUp(); + mPhone.Release(); + mPhone = null; + //mPhone.OnActivityDestroy(); } - } - + } + + public override void OnBackPressed() + { + if (mPhone != null) + mPhone.HangUp(); + else + Finish(); + } + public void OnClick(View v) { if (v.Equals(ivBack)) - { - this.Finish(); + { + if (mPhone != null) + mPhone.HangUp(); + else + Finish(); } } @@ -209,11 +225,12 @@ /// <summary> /// 寮瑰嚭宸叉寕鏂彁绀� /// </summary> - private void showTipDialog(string title, string text, string btnText) + private void showTipDialog(string title, string text, string btnText,bool isClose) { try { TipDiaglog diaglog = new TipDiaglog(this); + diaglog.SetAutoClose(isClose); diaglog.SetTitleText(title);//"鎻愮ず" diaglog.SetContentText(text);//"宸叉寕鏂�" diaglog.SetConfirmText(btnText);//"纭" @@ -292,8 +309,8 @@ TextProtocol tp = new TextProtocol(); tp.Parse(msg); - string event1 = tp.GetString("event"); - + string event1 = tp.GetString("event"); + switch (event1) { case "EVT_Ringing": @@ -327,7 +344,7 @@ { mPhone.StopStream(); } - showTipDialog("鎻愮ず","宸叉寕鏂�","纭"); + showTipDialog("鎻愮ず", "宸叉寕鏂�", "纭", true); break; case "EVT_RECV_CUSTOM_DATA": string data = tp.GetString("data"); @@ -337,12 +354,12 @@ int error = tp.GetInt("error"); string filePath = tp.GetString("filePath"); if (error == 0) - { - showTipDialog("鎻愮ず", "鎶撳浘鎴愬姛", "纭"); + { + showTipDialog("鎻愮ず", "鎶撳浘鎴愬姛", "纭", false); } else - { - showTipDialog("鎻愮ず", "鎶撳浘澶辫触\n\r" + error, "纭"); + { + showTipDialog("鎻愮ず", "鎶撳浘澶辫触\n\r" + error, "纭", false); } break; } @@ -363,10 +380,11 @@ //throw new NotImplementedException(); } - public void onSureClick(TipDiaglog dialoog, View v) + public void onSureClick(TipDiaglog dialoog, View v, bool bol) { - dialoog.Dismiss(); - this.Finish(); + dialoog.Dismiss(); + if (bol) + this.Finish(); } } } -- Gitblit v1.8.0