protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button1 = FindViewById<Button>(Resource.Id.MyButton);

            button1.Click += delegate
            {
                string dataBuffer = string.Format("Message from Android: {0}_{1}", count, Guid.NewGuid().ToString());
                var eventMessage = new Message(Encoding.UTF8.GetBytes(dataBuffer));
                deviceClient.SendEventAsync(eventMessage);
                button1.Text = string.Format("{0} messages sent to IotHub", count++);
            };

            Button button2 = FindViewById<Button>(Resource.Id.MyButton2);

            button2.Click += delegate
            {
                var asyncTask = Task.Run(() => this.deviceClient.ReceiveAsync());
                var receivedMessage = asyncTask.Result;
                var receivedMessagesTextBox = FindViewById<EditText>(Resource.Id.receivedMessagesTextBox);
                if (receivedMessage != null)
                {
                    receivedMessagesTextBox.Text += Encoding.Default.GetString(receivedMessage.GetBytes()) + "\r\n";
                }
                Console.WriteLine("Message received, now completing it...");
                Task.Run(() => { deviceClient.CompleteAsync(receivedMessage); });
                Console.WriteLine("Message completed.");
            };
        }
		public override void HandleMessage (Message msg)
		{
			// Ensure we have a valid message
			if (msg == null) {
				Log.Debug (TAG, "null msg");
				return;
			}

			if (msg.Data == null) {
				Log.Debug (TAG, "null msg.Data");
				return;
			}

			// Update the timer
			Log.Debug ("jpobst", msg.Data.GetString ("text"));
			timer_view.Text = msg.Data.GetString ("text");

			// If the user lost, set up the lost screen
			if (msg.Data.GetString ("STATE_LOSE") != null) {

				retry_button.Visibility = ViewStates.Visible;
				timer_view.Visibility = ViewStates.Invisible;
				text_view.Visibility = ViewStates.Visible;

				if (scores.HitTotal >= scores.SuccessThreshold) {
					text_view.SetText (Resource.String.winText);
				} else {
					string lost = string.Format ("Sorry, You Lose! You got {0}. You need {1} to win.", scores.HitTotal, scores.SuccessThreshold);
					text_view.Text = lost;
				}

				timer_view.Text = "1:12";
				text_view.SetHeight (20);
			}
		}
Exemple #3
0
 //--------------------------------------------------------------
 // PUBLIC METHODS
 //--------------------------------------------------------------
 public override void HandleMessage(Message message)
 {
     switch (message.What)
     {
     case (int) BluetoothManager.MessageType.StateChange:
         switch(message.Arg1)
         {
         case (int) BluetoothManager.StateEnum.Connected:
             Network.Instance.NotifyStateConnected((Network.ConnectionRole) message.Arg2);
             break;
         case (int) BluetoothManager.StateEnum.Connecting:
             Network.Instance.NotifyStateConnecting();
             break;
         case (int) BluetoothManager.StateEnum.Listen:
             Network.Instance.NotifyStateListen();
             break;
         case (int) BluetoothManager.StateEnum.None:
             Network.Instance.NotifyStateNone();
             break;
         }
         break;
     case (int) BluetoothManager.MessageType.Write:
         byte[] writeBuf = (byte[])message.Obj;
         Network.Instance.NotifyWriteMessage(writeBuf);
         break;
     case (int) BluetoothManager.MessageType.Read:
         byte[] readBuf = (byte[])message.Obj;
         Network.Instance.NotifyReadMessage(readBuf);
         break;
     case (int) BluetoothManager.MessageType.ConnectionLost:
         // We transfer the problem to the UI Activity
         Network.Instance.NotifyConnectionLost((byte[])message.Obj);
         break;
     }
 }
Exemple #4
0
        public void ShowActionSheet()
        {
            #region ActinSheet Items
            List<ActionSheetArgs> items = new List<ActionSheetArgs>();

            var alipayItem = new ActionSheetArgs("支付宝");
            alipayItem.OnClick += () =>
            {
                if (!AlipayHelper.CheckConfig())
                {
                    Toast.MakeText(ApplicationContext,
                        "系统异常.",
                        ToastLength.Long);
                    Log.Error(Tag, "Aplipay Config Exception ");
                    return;
                }
                string payInfo = AlipayHelper.GetPayInfo();
                // 完整的符合支付宝参数规范的订单信息
                Runnable payRunnable = new Runnable(() =>
                {
                    PayTask alipay = new PayTask(this);
                    // 调用支付接口,获取支付结果
                    string result = alipay.Pay(payInfo);

                    Message msg = new Message
                    {
                        What = (int)MsgWhat.AlipayPayFlag,
                        Obj = result
                    };
                    _handler.SendMessage(msg);
                });

                // 必须异步调用
                Thread payThread = new Thread(payRunnable);
                payThread.Start();
            };
            items.Add(alipayItem);
            var weixinItem = new ActionSheetArgs("微信");
            weixinItem.OnClick += () =>
            {
                Runnable wxpayRunnable = new Runnable(() =>
                {
                    _weixinpayHelper = new WeixinpayHelper(this);
                    _weixinpayHelper.Execute();
                });

                // 必须异步调用
                Thread payThread = new Thread(wxpayRunnable);
                payThread.Start();

            };
            items.Add(weixinItem);

            #endregion
            var menuView = new ActionSheet(this);
            menuView.SetCancelButtonTitle("取消");// before add items
            menuView.Items = items;
            menuView.CancelableOnTouchOutside = true;
            menuView.ShowMenu();
        }
            public override void HandleMessage (Message msg)
            {
                Log.Debug ("DemoMessengerService", msg.What.ToString ());

                string text = msg.Data.GetString ("InputText");

                Log.Debug ("DemoMessengerService", "InputText = " + text);
            }
Exemple #6
0
            public override void HandleMessage(Message msg)
            {
                base.HandleMessage(msg);

                if (msg.What == 369)
                {
                    action();
                }
            }
Exemple #7
0
        public void HandleMessage(Android.OS.Message msg)
        {
            switch (msg.What)
            {
            case BleMsgConsts.MSG_FINDING_BLE_SERVICES:
                _progressDialog.SetTitle(GetString(Resource.String.finding_ble_service));
                _progressDialog.Show();
                break;

            case BleMsgConsts.MSG_CREATING_READER:
                _progressDialog.SetTitle(GetString(Resource.String.creating_reader));
                _progressDialog.Show();
                break;

            case BleMsgConsts.MSG_CREATE_READER_SUCCESSFULLY:
                _progressDialog.Dismiss();
                Toast.MakeText(this, GetString(Resource.String.toast_create_reader_successfully), ToastLength.Short).Show();
                break;

            case BleMsgConsts.MSG_CREATE_READER_FAILED:
                _progressDialog.Dismiss();
                Toast.MakeText(this, GetString(Resource.String.toast_create_reader_failed), ToastLength.Short).Show();
                break;

            case BleMsgConsts.MSG_BT_SCAN_TIMEOUT:
                SearchTimeout();
                break;

            case BleMsgConsts.MSG_ON_BLE_DEV_FOUND:
                int             rssi   = msg.Arg1;
                BluetoothDevice device = (BluetoothDevice)msg.Obj;

                if (!_bleScanDevices.Any(x => x.Address == device.Address))
                {
                    _bleScanDevices.Add(device);
                    BleScanListAdapter.NotifyDataSetChanged();
                }

                _bleScanDevicesRssi[device.Address] = rssi;

                DateTime cur = DateTime.Now;

                var diffTime = cur - _prevListUpdateTime;

                if (diffTime.TotalMilliseconds > 250)
                {
                    BleScanListAdapter.NotifyDataSetChanged();
                    _prevListUpdateTime = cur;
                }
                break;

            case BleMsgConsts.MSG_DEALY_CREATE_READER:
                ReadyForCreateReader();
                break;
            }
        }
        public void HandleMessage(Android.OS.Message msg)
        {
            switch (msg.What)
            {
            case BleMsgConsts.MSG_FINDING_BLE_SERVICES:
                _progressDialog.SetTitle("Finding Devices");
                _progressDialog.Show();
                break;

            case BleMsgConsts.MSG_CREATING_READER:
                _progressDialog.SetTitle("Creating Reader");
                _progressDialog.Show();
                break;

            case BleMsgConsts.MSG_CREATE_READER_SUCCESSFULLY:
                _progressDialog.Dismiss();
                Toast.MakeText(this, "Created Reader", ToastLength.Short).Show();
                break;

            case BleMsgConsts.MSG_CREATE_READER_FAILED:
                _progressDialog.Dismiss();
                Toast.MakeText(this, "Reader Failed", ToastLength.Short).Show();
                break;

            case BleMsgConsts.MSG_BT_SCAN_TIMEOUT:
                SearchTimeout();
                break;

            case BleMsgConsts.MSG_ON_BLE_DEV_FOUND:
                int             rssi   = msg.Arg1;
                BluetoothDevice device = (BluetoothDevice)msg.Obj;

                if (!_bleScanDevices.Any(x => x.Address == device.Address))
                {
                    _bleScanDevices.Add(device);
                    _bleScanListAdapter.NotifyDataSetChanged();
                }

                _bleScanDevicesRssi[device.Address] = rssi;

                DateTime cur = DateTime.Now;

                var diffTime = cur - _prevListUpdateTime;

                if (diffTime.TotalMilliseconds > 250)
                {
                    _bleScanListAdapter.NotifyDataSetChanged();
                    _prevListUpdateTime = cur;
                }
                break;

            case BleMsgConsts.MSG_DEALY_CREATE_READER:
                _accessReadBtn.Enabled = true;
                break;
            }
        }
		public override void HandleMessage(Message msg){
			
		switch(msg.What){
			case SupportPreferenceFragment.MSG_BIND_PREFERENCES:
				if(_fragment != null){
					_fragment.BindPreferences();
				}
			break;
		}
		}
 public override void HandleMessage(Android.OS.Message msg)
 {
     switch (msg.What)
     {
     case MSG_DISMISS_TOOLTIP:
         if (parent.tipWindow != null && parent.tipWindow.IsShowing)
         {
             parent.tipWindow.Dismiss();
         }
         break;
     }
 }
            public override void HandleMessage(Message msg)
            {
                Message msg1 = Message.Obtain();
                Bundle bundle = new Bundle();
                bundle.PutString("arg1", "index.html");
                bundle.PutString("arg2", "http://www.vogella.com/index.html");
                msg1.Data = bundle;
                Messenger replyto = new Messenger(msg.ReplyTo.Binder);
                replyto.Send(msg1);

                 	         // Log.Error(this.Class.DeclaringClass.Class.Name, "Handlign message, ComputeService");
            }
         override public void HandleMessage(Message msg)
         {
            if (msg.What != WHAT_SIGNED_IN)
            {
               return;
            }

            Android.App.Activity activity = mFragment.GetActivity();
            if (mFragment.mPlusClient.IsConnected() && activity is OnSignedInListener)
            {
               ((OnSignedInListener)activity).OnSignedIn(mFragment.mPlusClient);
            }
         }
Exemple #13
0
		/// <summary>
		/// hanlder回调函数
		/// </summary>
		/// <param name="msg">Message.</param>
		private void DealMessage(Message msg)
		{
			switch (msg.What) {
			case MSG_SET_ALIAS:
				Log.Debug (Tag,"设置aliasname");
				JPushInterface.SetAlias (context, (string)msg.Obj, this);
				break;
			case MSG_SET_TAGS:
				Log.Debug (Tag,"设置tag标签");
				JPushInterface.SetTags (context, (ICollection<string>)msg.Obj, this);
				break;

			}
		}
		//Continually sends and recieves messages to cycle through the colors
		public override void HandleMessage (Message msg)
		{
			//Cycle through every combination of the colors in the array
			v.current_color = v.GetColor (v.progress, v.colors [v.from_color_index], v.colors [v.to_color_index]);
			v.PostInvalidate ();
			v.progress += 0.1f;
			if (v.progress > 1.0) {
				v.from_color_index = v.to_color_index;
				v.to_color_index++;
				if (v.to_color_index >= v.colors.Length)
					v.to_color_index = 0;

			}
			v.handler.SendEmptyMessageDelayed (0, 100);
		}
            public override void HandleMessage(Android.OS.Message msg)
            {
                switch (msg.What)
                {
                case MESSAGE_RETRY_CONNECTION:

                    FullWalletConfirmationButtonFragment fragment = null;
                    mWeakReference.TryGetTarget(out fragment);

                    if (fragment != null)
                    {
                        fragment.mGoogleApiClient.Connect();
                    }

                    break;
                }
            }
Exemple #16
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     SetContentView(Resource.Layout.Main);
     var button = FindViewById<Button>(Resource.Id.MyButton);
     var alipayHandler=new AlipayHandler();
     button.Click += delegate
     {
         var payTask = new PayTask(this);
         var order =
             "partner=\"2088001152192050\"&seller_id=\"[email protected]\"&out_trade_no=\"w2413209423\"&subject=\"payw2413209423\"&body=\"payw2413209423\"&total_fee=\"0.01\"&notify_url=\"http://221.122.53.190:6804/NewWebPay/FromPhoneAlipay.aspx\"&service=\"mobile.securitypay.pay\"&payment_type=\"1\"&_input_charset=\"utf-8\"&sign=\"E0tHnnq40wfnMn6G6T54%2fBmshvUlSUYAcWhgZjoxQu02W8gspQFHogCDDAmnfo9WFUG%2b%2f32x8IIl1hUkaK9sqP64Fvk6PnIyMgoms8en1PpIL0Z4VUSsqjtGrOVrhwfOnb5sWlPATEu7MuXWnoH1yp%2fWJdyPdHmzljEF%2fFINyZE%3d\"&sign_type=\"RSA\"";
         var result = payTask.Pay(order);
         var msg = new Message
         {
             Obj = result
         };
         alipayHandler.SendMessage(msg);
     };
 }
Exemple #17
0
        private void BeginReadInternal()
        {
            _app.RfidMgr.SetLEDBlink(true);


            IsReading_fast = true;

            SetQuickModeParams();

            string     additionDataType = "None";
            RfidReader reader           = GetReader();

            reader.SetOnTagReadListener(_dataListener);
            reader.Read(TagAdditionData.Get(additionDataType), TagReadOption);


            Android.OS.Message msg = Android.OS.Message.Obtain();
            msg.What = MSG_UPDATE_UI_FAST_MODE;
            _uiHandler.SendMessage(msg);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="m"></param>
 private void BackgroundThreadMessageHandler(Message m)
 {
    string message = string.Empty;
    switch(m.What)
    {
        case 404:
            var details = m.Data.GetString("error");
            message = "Authentication Failed, make sure the credentials you are using are correct and linked to Azure AD.\nDetails: " + details;
            break;
        default:
            message = "Unknown error";
            break;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.SetTitle("Error");
    builder.SetMessage(message);
    builder.Create().Show();
    var loginBtn = FindViewById<Button>(Resource.Id.loginBtn);
    loginBtn.Text = "Login";
 }
Exemple #19
0
 public override void HandleMessage(Message msg)
 {
     base.HandleMessage(msg);
     switch (msg.What)
     {
         case 0:
             // 移除
             TextView tvTemp = (TextView)msg.Obj;
             //Log.d("tag", "out->" + tvTemp.getId());
             tvTemp.StartAnimation(anim_out);
             tvTemp.Visibility = (ViewStates.Gone);
             break;
         case 1:
             // 进入
             TextView tvTemp2 = (TextView)msg.Obj;
             //Log.d("tag", "in->" + tvTemp2.getId());
             tvTemp2.StartAnimation(anim_in);
             tvTemp2.Visibility = ViewStates.Visible;
             break;
     }
 }
        private void ShowPopupForChooseAction(Message msg)
        {
            _flagClickButtons = true;

            _onButtonDelete = delegate { if (_flagClickButtons){

                App.Instance.Popup.MsgBoxClose();

                _contactsHandler.ContactDelete(
                    _contactsHandler.FoundUri[_contactsHandler.CurrentContactIndex]);
                    _contactsHandler.Resume();
                    _flagClickButtons = !_flagClickButtons;
                }
            };

            _onButtonJoin = delegate {
                if (_flagClickButtons){

                App.Instance.Popup.MsgBoxClose();
                _contactsHandler.ContactJoin (
                    _contactsHandler.FoundUri [_contactsHandler.CurrentContactIndex]);
                _contactsHandler.Resume();
                    _flagClickButtons = !_flagClickButtons;
                }
            };

            _onButtonIgnore = delegate {
                if (_flagClickButtons){

                App.Instance.Popup.MsgBoxClose();
                _contactsHandler.ContactIgnore();
                    _contactsHandler.Resume();
                    _flagClickButtons = !_flagClickButtons;
                }
            };

            //			App.Instance.ProgressShower.Cancel ();

            App.Instance.Popup.MsgBoxButtons ("What do with:", msg.Obj.ToString () + " ?", "Delete", "Join", "Ignore", _onButtonDelete, _onButtonJoin, _onButtonIgnore, true);
        }
Exemple #21
0
        public void handleMessage(Android.OS.Message msg)
        {
            int i = msg.What;

            if (i == 0)

            {
                byte[] byteArray = (byte[])msg.Obj;
                if (byteArray != null)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append("Result:");
                    stringBuilder.Append(new Java.Lang.String(byteArray));
                    stringBuilder.Append("\nHEX:");

                    stringBuilder.Append(BytesToHex(byteArray));
                    // access$000.setText(stringBuilder.toString());
                    Char[] array = System.Text.Encoding.UTF8.GetString(byteArray).ToCharArray();
                    new Android.App.Instrumentation().SendStringSync(new string(array));
                }
            }
        }
 public override void HandleMessage(Message msg)
 {
     switch (msg.What) {
     case (int)MessageType.AddToLogView:
         AddToLogView (msg);
         break;
     case (int)MessageType.ShowPopupForChooseAction:
         ShowPopupForChooseAction (msg);
         break;
     case (int)MessageType.SetTextToLogView:
         SetTextToLogView (msg);
         break;
     case (int)MessageType.ShowProgress:
         ShowProgress(msg);
         break;
     case (int)MessageType.Finally:
         Finally();
         break;
     case (int)MessageType.SetProgressBar:
         SetProgressBar(msg);
         break;
     }
 }
        private void AlipayPay(object sender, EventArgs args)
        {


            if (!AliPayHelper.CheckConfig())
            {
                Toast.MakeText(ApplicationContext,
                    "系统异常.",
                    ToastLength.Long);
                Log.Error(Tag, "Aplipay Config Exception ");
                return;
            }
            string payInfo = AliPayHelper.GetPayInfo();
            // 完整的符合支付宝参数规范的订单信息
            Runnable payRunnable = new Runnable(() =>
            {
                PayTask alipay = new PayTask(this);
                // 调用支付接口,获取支付结果
                string result = alipay.Pay(payInfo);

                Message msg = new Message
                {
                    What = (int)MsgWhat.AlipayPayFlag,
                    Obj = result
                };
                _handler.SendMessage(msg);
            });

            // 必须异步调用
            Thread payThread = new Thread(payRunnable);
            payThread.Start();
        }
        private void TecentPayPay(object sender, EventArgs args)
        {
            _msgApi.RegisterApp(Constants.AppId);


            var checkRunnable = new Runnable(() =>
            {


                string url = string.Format("https://api.mch.weixin.qq.com/pay/unifiedorder");
                string entity = GenProductArgs();
                var buf = Util.httpPost(url, entity);

                string content = System.Text.Encoding.Default.GetString(buf);
                _resultunifiedorder = DecodeXml(content);
                var msg = new Message
                {
                    What = (int)MsgWhat.TencentValidateFlag,
                    Obj = content
                };
                _handler.SendMessage(msg);
            });

            Java.Lang.Thread checkThread = new Java.Lang.Thread(checkRunnable);
            checkThread.Start();

        }
 public override void HandleMessage(Message msg)
 {
     AppMsg appMsg;
     switch (msg.What)
     {
         case MESSAGE_DISPLAY:
             {
                 DisplayMsg();
             }
             break;
         case MESSAGE_ADD_VIEW:
             {
                 appMsg = msg.Obj as AppMsg;
                 AddMsgToView(appMsg);
             }
             break;
         case MESSAGE_REMOVE:
             {
                 appMsg = msg.Obj as AppMsg;
                 RemoveMsg(appMsg);
             }
             break;
         default:
             {
                 base.HandleMessage(msg);
             }
             break;
     }
 }
		public override void HandleMessage (Message msg)
		{
			view.Update ();
			view.Invalidate ();
		}
Exemple #27
0
		private void AddMessage(LinearLayout messageList, Message elem) {
			View v = null;
			if (elem.text.StartsWith ("#image")) {
				if (elem.nick == user.user) {
					if (setting.FontSize == Setting.Size.large) {
						v = LayoutInflater.Inflate (Resource.Layout.ImageRightLarge, null);
					} else {
						v = LayoutInflater.Inflate (Resource.Layout.ImageRight, null);
					}
				} else {
					if (setting.FontSize == Setting.Size.large) {
						v = LayoutInflater.Inflate (Resource.Layout.ImageLeftLarge, null);
					} else {
						v = LayoutInflater.Inflate (Resource.Layout.ImageLeft, null);
					}
					ImageView image = v.FindViewById<ImageView> (Resource.Id.messageImage);
					new Thread (async () => {
						try {
							var imageBitmap = await network.GetImageBitmapFromUrl (Resources.GetString (Resource.String.profileUrl) + elem.nick + ".png");
							RunOnUiThread (() => image.SetImageBitmap (imageBitmap));
						} catch (Exception e) {
							Log.Error ("BlaChat", e.StackTrace);
						}
					}).Start ();
				}
				ImageView contentImage = v.FindViewById<ImageView> (Resource.Id.contentImage);
				contentImage.Click += delegate {
					string images = System.IO.Path.Combine (Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "Pictures/BlaChat");
					var filename = elem.text.Substring ("#image ".Length);
					filename = filename.Substring (filename.LastIndexOf ("/") + 1);
					filename = System.IO.Path.Combine (images, filename);
					Intent intent = new Intent (Intent.ActionView);
					intent.SetDataAndType (Android.Net.Uri.Parse ("file://" + filename), "image/*");
					StartActivity (intent);
				};
				//contentImage.SetOnTouchListener (new TouchListener(this, elem.text.Substring ("#image ".Length)));

				new Thread (async () => {
					try {
						var uri = elem.text.Substring ("#image ".Length);
						var imageBitmap = await network.GetImageBitmapFromUrl (uri);
						RunOnUiThread (() => contentImage.SetImageBitmap (imageBitmap));
					} catch (Exception e) {
						Log.Error ("BlaChat", e.StackTrace);
					}
				}).Start ();
			} else {
				if (elem.nick == user.user) {
					if (setting.FontSize == Setting.Size.large) {
						v = LayoutInflater.Inflate (Resource.Layout.MessageRightLarge, null);
					} else {
						v = LayoutInflater.Inflate (Resource.Layout.MessageRight, null);
					}
				} else {
					if (setting.FontSize == Setting.Size.large) {
						v = LayoutInflater.Inflate (Resource.Layout.MessageLeftLarge, null);
					} else {
						v = LayoutInflater.Inflate (Resource.Layout.MessageLeft, null);
					}
					ImageView image = v.FindViewById<ImageView> (Resource.Id.messageImage);
					new Thread (async () => {
						try {
							var imageBitmap = await network.GetImageBitmapFromUrl (Resources.GetString (Resource.String.profileUrl) + elem.nick + ".png");
							RunOnUiThread (() => image.SetImageBitmap (imageBitmap));
						} catch (Exception e) {
							Log.Error ("BlaChat", e.StackTrace);
						}
					}).Start ();
				}
				TextView text = v.FindViewById<TextView> (Resource.Id.messageText);
				var escape = elem.text.Replace ("&quot;", "\"");
				escape = escape.Replace ("&lt;", "<");
				escape = escape.Replace ("&gt;", ">");
				escape = escape.Replace ("&amp;", "&");
				text.TextFormatted = SpannableTools.GetSmiledText (this, new SpannableString (escape));
			}

			TextView caption = v.FindViewById<TextView> (Resource.Id.messageCaption);
			if (elem.nick != user.user) {
				caption.TextFormatted = SpannableTools.GetSmiledText (this, new SpannableString (elem.author + " (" + elem.time.Substring (11, 5) + ")"));
			} else {
				if (elem.time == "sending") {
					caption.TextFormatted = SpannableTools.GetSmiledText (this, new SpannableString ("Du (" + elem.time + ")"));
				} else {
					caption.Text = "Du (" + elem.time.Substring (11, 5) + ")";
				}
			}
			messageList.AddView (v);
		}
        /**
	 * check whether the device has authentication alipay account.
	 * 查询终端设备是否存在支付宝认证账户
	 * 
	 */
        public void check(object o, EventArgs e)
        {
            Runnable checkRunnable = new Runnable(()=> {
                PayTask payTask = new PayTask(this);
                // 调用查询接口,获取查询结果
                bool isExist = payTask.CheckAccountIfExist();

                Message msg = new Message();
                msg.What = SDK_CHECK_FLAG;
                msg.Obj = isExist;
                mHandler.SendMessage(msg);
            });

            Thread checkThread = new Thread(checkRunnable);
            checkThread.Start();

        }
        public void pay(object o, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(PARTNER) || string.IsNullOrWhiteSpace(RSA_PRIVATE)
                    || string.IsNullOrWhiteSpace(SELLER))
            {
                new AlertDialog.Builder(this)
                        .SetTitle("警告")
                        .SetMessage("需要配置PARTNER | RSA_PRIVATE| SELLER")
                        .SetPositiveButton("确定", (dialoginterface, i) => { Finish(); }

                                ).Show();
                return;
            }
            // 订单
            string orderInfo = GetOrderInfo("测试的商品", "该测试商品的详细描述", "0.01");

            // 对订单做RSA 签名
            string sign = Sign(orderInfo);
            try
            {
                // 仅需对sign 做URL编码
                sign = Java.Net.URLEncoder.Encode(sign, "UTF-8");
            }
            catch (UnsupportedEncodingException ex)
            {
                ex.PrintStackTrace();
            }
            finally
            {
                string payInfo = orderInfo + "&sign=\"" + sign + "\"&"
                                + GetSignType();
                // 完整的符合支付宝参数规范的订单信息
                Runnable payRunnable = new Runnable(()=> {
                    PayTask alipay = new PayTask(this);
                    // 调用支付接口,获取支付结果
                    string result = alipay.Pay(payInfo);

                    Message msg = new Message();
                    msg.What = SDK_PAY_FLAG;
                    msg.Obj = result;
                    mHandler.SendMessage(msg);
                });
                
                // 必须异步调用
                Thread payThread = new Thread(payRunnable);
                payThread.Start();
            }


        }
 public void handleMessage(Message msg)
 {
     
 }
			public override void HandleMessage (Message msg)
			{
				MessagingService service;
				mReference.TryGetTarget (out service);
				switch (msg.What) {
				case MSG_SEND_NOTIFICATION:
					int howManyConversations = msg.Arg1 <= 0 ? 1 : msg.Arg1;
					int messagesPerConversation = msg.Arg2 <= 0 ? 1 : msg.Arg2;
					if (service != null) {
						service.SendNotification (howManyConversations, messagesPerConversation);
					}
					break;
				default:
					HandleMessage (msg);
					break;
				}
			}
Exemple #32
0
 public override void HandleMessage(Message msg)
 {
     switch (msg.What)
     {
         case MESSAGE_STATE_CHANGE:
             if (D)
                 Log.I(TAG, "MESSAGE_STATE_CHANGE: " + msg.Arg1);
             switch (msg.Arg1)
             {
                 case BluetoothChatService.STATE_CONNECTED:
                     chat.SetStatus(chat.GetString(R.String.title_connected_to, chat.mConnectedDeviceName));
                     chat.mConversationArrayAdapter.Clear();
                     break;
                 case BluetoothChatService.STATE_CONNECTING:
                     chat.SetStatus(R.String.title_connecting);
                     break;
                 case BluetoothChatService.STATE_LISTEN:
                 case BluetoothChatService.STATE_NONE:
                     chat.SetStatus(R.String.title_not_connected);
                     break;
             }
             break;
         case MESSAGE_WRITE:
             byte[] writeBuf = (byte[])msg.Obj;
             // construct a string from the buffer
             var writeMessage = new string(writeBuf);
             chat.mConversationArrayAdapter.Add("Me:  " + writeMessage);
             break;
         case MESSAGE_READ:
             byte[] readBuf = (byte[])msg.Obj;
             // construct a string from the valid bytes in the buffer
             var readMessage = new string(readBuf, 0, msg.Arg1);
             chat.mConversationArrayAdapter.Add(chat.mConnectedDeviceName + ":  " + readMessage);
             break;
         case MESSAGE_DEVICE_NAME:
             // save the connected device's name
             chat.mConnectedDeviceName = msg.Data.GetString(DEVICE_NAME);
             Toast.MakeText(chat.GetApplicationContext(), "Connected to " + chat.mConnectedDeviceName, Toast.LENGTH_SHORT).Show();
             break;
         case MESSAGE_TOAST:
             Toast.MakeText(chat.GetApplicationContext(), msg.Data.GetString(TOAST), Toast.LENGTH_SHORT).Show();
             break;
     }
 }
        private void ShowProgress(Message msg)
        {
            EventHandler cancel = delegate {
                _contactsHandler.Pause();
                Finally();
            };

            //			App.Instance.ProgressShower.Progress = msg.Arg2;

            //			while (App.Instance.ProgressShower.Progress != msg.Arg2) {
            //				App.Instance.ProgressShower.Progress = msg.Arg2;
            //			}
            //				App.Instance.ProgressShower.Max = msg.Arg1;
            //			App.Instance.ProgressShower.SetMessage (msg.Obj.ToString ());
            //			App.Instance.ProgressShower.Show ();
            App.Instance.Popup.MsgBoxProgress("Processing...",msg.Obj.ToString(),true, msg.Arg1, msg.Arg2, cancel);
        }
 private void SetTextToLogView(Message msg)
 {
     _logView.SetText (msg.Obj.ToString (), TextView.BufferType.Normal);
 }
 private void SetProgressBar(Message msg)
 {
     App.Instance.Popup.ProgressBar.Max = msg.Arg1;
     App.Instance.Popup.ProgressBar.Progress = msg.Arg2;
 }
 private void AddToLogView(Message msg)
 {
     _logView.Append (msg.Obj.ToString ());
 }