黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/GateWay.Droid/FengLinVideo/Forms/MonitorFragment.cs
@@ -28,6 +28,7 @@
        private RelativeLayout rlUnlock;
        private ImageView imgUnlock;
        private TextView tvUnlock;
        private System.Threading.Thread thread = null;
        public MonitorFragment(VideoPhone phone)
        {
@@ -89,22 +90,44 @@
        //更新开锁按钮状态
        private void updataUnlockState()
        {
            //开锁成功,15秒内不给再点击按钮
            rlUnlock.Enabled = false;
            imgUnlock.SetImageResource(Resource.Drawable.unlock_disable);
            tvUnlock.SetTextColor(new Color(Activity.GetColor(Resource.Color.color_disable)));
            new System.Threading.Thread(() =>
            {
                System.Threading.Thread.Sleep(15 * 1000);
                Activity.RunOnUiThread(() =>
                {
                    rlUnlock.Enabled = true;
                    imgUnlock.SetImageResource(Resource.Drawable.unlock);
                    tvUnlock.SetTextColor(new Color(Activity.GetColor(Resource.Color.text_color)));
                });
            }).Start();
        {
            try
            {
                //开锁成功,15秒内不给再点击按钮
                rlUnlock.Enabled = false;
                imgUnlock.SetImageResource(Resource.Drawable.unlock_disable);
                tvUnlock.SetTextColor(new Color(Activity.GetColor(Resource.Color.color_disable)));
                if (thread != null)
                {
                    try
                    {
                        thread.Interrupt();
                    }
                    catch { }
                    thread = null;
                }
                thread = new System.Threading.Thread(() =>
                  {
                      try
                      {
                          System.Threading.Thread.Sleep(15 * 1000);
                          Activity.RunOnUiThread(() =>
                          {
                              try
                              {
                                  rlUnlock.Enabled = true;
                                  imgUnlock.SetImageResource(Resource.Drawable.unlock);
                                  tvUnlock.SetTextColor(new Color(Activity.GetColor(Resource.Color.text_color)));
                              }
                              catch { }
                          });
                      }
                      catch { }
                  });
                thread.Start();
            }
            catch { }
        }
        public void OnClick(View v)
@@ -112,7 +135,8 @@
            //
            if (v.Equals(rlUnlock))
            {
                unlock();
                if (mPhone != null)
                    unlock();
            }
            else if (v.Equals(rlScreenshot))
            {
@@ -194,5 +218,20 @@
                string error = e.Message;
            }
        }
        public override void OnDestroy()
        {
            base.OnDestroy();
            if (thread != null)
            {
                try
                {
                    thread.Interrupt();
                }
                catch { }
                thread = null;
            }
        }
    }
}