| | |
| | | |
| | | using System.Threading; |
| | | using Android.App; |
| | | using Android.Icu.Text; |
| | | using Android.OS; |
| | | using Android.Views; |
| | | using Android.Widget; |
| | | using Java.Util; |
| | | //using System.Threading; |
| | | //using Android.App; |
| | | //using Android.Icu.Text; |
| | | //using Android.OS; |
| | | //using Android.Views; |
| | | //using Android.Widget; |
| | | //using Java.Util; |
| | | |
| | | namespace HDL_ON_Android.LeChengView.Form |
| | | { |
| | | public class MonitorFragment : Fragment, View.IOnClickListener |
| | | { |
| | | //namespace HDL_ON_Android.LeChengView.Form |
| | | //{ |
| | | // public class MonitorFragment : Fragment, View.IOnClickListener |
| | | // { |
| | | |
| | | private View mView; |
| | | // private View mView; |
| | | |
| | | // 截图 |
| | | private LinearLayout screenshotLayout; |
| | | private ImageView screenImage; |
| | | private TextView ScreenText; |
| | | // // 截图 |
| | | // private LinearLayout screenshotLayout; |
| | | // private ImageView screenImage; |
| | | // private TextView ScreenText; |
| | | |
| | | //开锁 |
| | | private LinearLayout unlockLayout; |
| | | private ImageView unlockImag; |
| | | private TextView unlockText; |
| | | // //开锁 |
| | | // private LinearLayout unlockLayout; |
| | | // private ImageView unlockImag; |
| | | // private TextView unlockText; |
| | | |
| | | // 更新线程 |
| | | private Thread thread = null; |
| | | // // 更新线程 |
| | | // private Thread thread = null; |
| | | |
| | | private LeChengVideoActivity CurtActivity; |
| | | // private LeChengVideoActivity CurtActivity; |
| | | |
| | | public override void OnCreate(Bundle savedInstanceState) |
| | | { |
| | | base.OnCreate(savedInstanceState); |
| | | // public override void OnCreate(Bundle savedInstanceState) |
| | | // { |
| | | // base.OnCreate(savedInstanceState); |
| | | |
| | | CurtActivity = (LeChengVideoActivity)this.Activity; |
| | | } |
| | | // CurtActivity = (LeChengVideoActivity)this.Activity; |
| | | // } |
| | | |
| | | public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) |
| | | { |
| | | mView = inflater.Inflate(Resource.Layout.fragment_monitor, container, false); |
| | | // public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) |
| | | // { |
| | | // mView = inflater.Inflate(Resource.Layout.fragment_monitor, container, false); |
| | | |
| | | IniView(); |
| | | // IniView(); |
| | | |
| | | CurtActivity.Play(); |
| | | CurtActivity.OpenAudio(); |
| | | // CurtActivity.Play(); |
| | | // CurtActivity.OpenAudio(); |
| | | |
| | | return mView; |
| | | } |
| | | // 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); |
| | | // 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 = (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); |
| | | } |
| | | // unlockLayout.SetOnClickListener(this); |
| | | // screenshotLayout.SetOnClickListener(this); |
| | | // } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 开锁 |
| | | /// </summary> |
| | | private void Unlock() |
| | | { |
| | | // |
| | | CurtActivity.Unlock(); |
| | | UpdataUnlockState(); |
| | | } |
| | | // /// <summary> |
| | | // /// 开锁 |
| | | // /// </summary> |
| | | // private void Unlock() |
| | | // { |
| | | // // |
| | | // CurtActivity.Unlock(); |
| | | // UpdataUnlockState(); |
| | | // } |
| | | |
| | | /// <summary> |
| | | /// 更新开锁按钮状态 |
| | | /// </summary> |
| | | private void UpdataUnlockState() |
| | | { |
| | | try |
| | | { |
| | | //开锁成功,15秒内不给再点击按钮 |
| | | unlockLayout.Enabled = false; |
| | | if (thread != null) |
| | | { |
| | | try |
| | | { |
| | | thread.Interrupt(); |
| | | } |
| | | catch { } |
| | | thread = null; |
| | | } |
| | | // /// <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); |
| | | // thread = new Thread(() => |
| | | // { |
| | | // try |
| | | // { |
| | | // Thread.Sleep(15 * 1000); |
| | | |
| | | Activity.RunOnUiThread(() => |
| | | { |
| | | if (unlockLayout != null) |
| | | unlockLayout.Enabled = true; |
| | | }); |
| | | } |
| | | catch { } |
| | | }); |
| | | // Activity.RunOnUiThread(() => |
| | | // { |
| | | // if (unlockLayout != null) |
| | | // unlockLayout.Enabled = true; |
| | | // }); |
| | | // } |
| | | // catch { } |
| | | // }); |
| | | |
| | | thread.Start(); |
| | | } |
| | | catch { } |
| | | } |
| | | // thread.Start(); |
| | | // } |
| | | // catch { } |
| | | // } |
| | | |
| | | public void OnClick(View v) |
| | | { |
| | | // |
| | | if (v.Equals(unlockLayout)) |
| | | { |
| | | //开锁 |
| | | Unlock(); |
| | | } |
| | | else if (v.Equals(screenshotLayout)) |
| | | { |
| | | //有视频过来可调用此接口进行拍照 |
| | | screenImage.Selected = true; |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | string time = format.Format(new Date(SystemClock.CurrentThreadTimeMillis())); |
| | | string ss = Android.OS.Environment.ExternalStorageDirectory.Path + "/DCIM/HDL"; |
| | | string path = ss + "/" + time + ".jpg"; |
| | | CurtActivity.SnapShot(path); |
| | | } |
| | | } |
| | | // public void OnClick(View v) |
| | | // { |
| | | // // |
| | | // if (v.Equals(unlockLayout)) |
| | | // { |
| | | // //开锁 |
| | | // Unlock(); |
| | | // } |
| | | // else if (v.Equals(screenshotLayout)) |
| | | // { |
| | | // //有视频过来可调用此接口进行拍照 |
| | | // screenImage.Selected = true; |
| | | // SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | // string time = format.Format(new Date(SystemClock.CurrentThreadTimeMillis())); |
| | | // string ss = Android.OS.Environment.ExternalStorageDirectory.Path + "/DCIM/HDL"; |
| | | // string path = ss + "/" + time + ".jpg"; |
| | | // CurtActivity.SnapShot(path); |
| | | // } |
| | | // } |
| | | |
| | | public override void OnDestroy() |
| | | { |
| | | base.OnDestroy(); |
| | | // public override void OnDestroy() |
| | | // { |
| | | // base.OnDestroy(); |
| | | |
| | | if (thread != null) |
| | | { |
| | | try |
| | | { |
| | | thread.Interrupt(); |
| | | } |
| | | catch { } |
| | | thread = null; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // if (thread != null) |
| | | // { |
| | | // try |
| | | // { |
| | | // thread.Interrupt(); |
| | | // } |
| | | // catch { } |
| | | // thread = null; |
| | | // } |
| | | // } |
| | | // } |
| | | //} |