Ejemplo n.º 1
0
 public override void HandleMessage(Message m)
 {
     view.mStatusText.SetVisibility(m.GetData().GetInt("viz"));
     view.mStatusText.SetText(m.GetData().GetString("text"));
 }
Ejemplo n.º 2
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.Strings.title_connected_to, chat.mConnectedDeviceName));
                     chat.mConversationArrayAdapter.Clear();
                     break;
                 case BluetoothChatService.STATE_CONNECTING:
                     chat.SetStatus(R.Strings.title_connecting);
                     break;
                 case BluetoothChatService.STATE_LISTEN:
                 case BluetoothChatService.STATE_NONE:
                     chat.SetStatus(R.Strings.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.GetData().GetString(DEVICE_NAME);
             Toast.MakeText(chat.GetApplicationContext(), "Connected to " + chat.mConnectedDeviceName, Toast.LENGTH_SHORT).Show();
             break;
         case MESSAGE_TOAST:
             Toast.MakeText(chat.GetApplicationContext(), msg.GetData().GetString(TOAST), Toast.LENGTH_SHORT).Show();
             break;
     }
 }