コード例 #1
0
 @Override
 public void run() {
   if (isRun) {
     Vibrate v = list.get(point);
     if (AotoBlueToothManager.getInstance()
         .getDeviceName()
         .equals(AotoGattAttributes.SMART_MINI_VIBE))
       arrayOfByte = AotoGattAttributes.initArrayOfByte(v.getRate());
     else arrayOfByte = AotoGattAttributes.initIBallData(v.getRate());
     AotoBlueToothManager.getInstance().getCurrentCharacteristic().setValue(arrayOfByte);
     AotoBlueToothManager.getInstance().wirteCharacteristic();
     if (point == total - 1) point = 0;
     else point++;
     handler.postDelayed(runnable, v.getTime());
   }
 }
コード例 #2
0
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
  private void stopDevice() {
    isRun = false;
    handler.removeCallbacks(runnable);
    byte[] arrayOfByte = null;
    if (AotoBlueToothManager.getInstance()
        .getDeviceName()
        .equals(AotoGattAttributes.SMART_MINI_VIBE)) {
      arrayOfByte = AotoGattAttributes.initArrayOfByte(0);
    } else if (AotoBlueToothManager.getInstance()
            .getDeviceName()
            .equals(AotoGattAttributes.WOLKAMO_BIU)
        || AotoBlueToothManager.getInstance()
            .getDeviceName()
            .equals(AotoGattAttributes.WOLKAMO_MONA)) {
      arrayOfByte = new byte[] {0};
    } else if (AotoBlueToothManager.getInstance()
        .getDeviceName()
        .equals(AotoGattAttributes.IBALL)) {
      arrayOfByte = AotoGattAttributes.initIBallData(0);
    } else if (AotoBlueToothManager.getInstance()
            .getDeviceName()
            .startsWith(AotoGattAttributes.XAIAI)
        || AotoBlueToothManager.getInstance()
            .getDeviceName()
            .startsWith(AotoGattAttributes.XAIAIF)) {
      arrayOfByte = new byte[] {8, 17, 6, 15, 1, 1, 0, 48};
    }

    if (shakeView != null) {
      shakeView.clearAnimation();
      shakeView = null;
    }
    shakePostion = -1;
    AotoBlueToothManager.getInstance().getCurrentCharacteristic().setValue(arrayOfByte);
    AotoBlueToothManager.getInstance().wirteCharacteristic();
  }