Esempio n. 1
0
 public Message obtainMessage(What notification) {
   return super.obtainMessage(notification.v());
 }
Esempio n. 2
0
 public Message obtainMessage(What readData, int bytes, int i, byte[] buffer) {
   return super.obtainMessage(readData.v(), bytes, i, buffer);
 }
Esempio n. 3
0
  @Override
  public void handleMessage(final Message msg) {
    final BluetoothState state = BluetoothState.fromInt(msg.what);
    Bundle data = null;
    if (msg != null) {
      data = msg.getData();
    }

    What what = What.fromInt(msg.what);
    switch (what) {
      case CONNECTED_TO:
        {
          String deviceAddress = data.getString(Data.DEVICE_NAME.v());
          float connectionTime = data.getFloat(Data.EVENT_TIME.v());
          onCONNECTED_TO(state, msg, deviceAddress, connectionTime);
          break;
        }
      case ERROR:
        {
          String deviceAddress = data.getString(Data.DEVICE_NAME.v());
          float errorTime = data.getFloat(Data.EVENT_TIME.v());
          int errorMessage = data.getInt(Data.MESSAGE.v());
          onERROR(state, msg, errorMessage, deviceAddress, errorTime);
          break;
        }
      case NOTIFICATION:
        {
          float errorTime = data.getFloat(Data.EVENT_TIME.v());
          int message = data.getInt(Data.MESSAGE.v());
          onNOTIFICATION(state, msg, message, errorTime);
          break;
        }
      case READ_DATA:
        onREAD_DATA(state, msg);
        break;
      case READ_BEGIN:
        onREAD_BEGIN(state, msg);
        break;
      case READ_TURN:
        onREAD_TURN(state, msg);
        break;
      case READ_REAL_TIME:
        onREAD_REAL_TIME(state, msg);
        break;
      case READ_FINISH:
        onREAD_FINISH(state, msg);
        break;
      case WRITE_BEGIN:
        onWRITE_BEGIN(state, msg);
        break;
      case WRITE_DATA:
        onWRITE_DATA(state, msg);
        break;
      case WRITE_TURN:
        onWRITE_TURN(state, msg);
        break;
      case WRITE_REAL_TIME:
        onWRITE_REAL_TIME(state, msg);
        break;
      case WRITE_FINISH:
        onWRITE_FINISH(state, msg);
        break;
      default:
        // TODO error unexpected message arrived
        break;
    }
  }