Java Code Examples for com.vise.log.ViseLog#i()
The following examples show how to use
com.vise.log.ViseLog#i() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeviceMirror.java From BLE with Apache License 2.0 | 6 votes |
/** * 连接失败处理 * * @param bleException 回调异常 */ private void connectFailure(BleException bleException) { if (connectRetryCount < BleConfig.getInstance().getConnectRetryCount()) { connectRetryCount++; if (handler != null) { handler.removeMessages(MSG_CONNECT_TIMEOUT); handler.sendEmptyMessageDelayed(MSG_CONNECT_RETRY, BleConfig.getInstance().getConnectRetryInterval()); } ViseLog.i("connectFailure connectRetryCount is " + connectRetryCount); } else { if (bleException instanceof TimeoutException) { connectState = ConnectState.CONNECT_TIMEOUT; } else { connectState = ConnectState.CONNECT_FAILURE; } close(); if (connectCallback != null) { connectCallback.onConnectFailure(bleException); } ViseLog.i("connectFailure " + bleException); } }
Example 2
Source File: BluetoothDeviceManager.java From BLE with Apache License 2.0 | 6 votes |
@Override public void onSuccess(final byte[] data, BluetoothGattChannel bluetoothGattInfo, BluetoothLeDevice bluetoothLeDevice) { if (data == null) { return; } ViseLog.i("callback success:" + HexUtil.encodeHexStr(data)); BusManager.getBus().post(callbackDataEvent.setData(data).setSuccess(true) .setBluetoothLeDevice(bluetoothLeDevice) .setBluetoothGattChannel(bluetoothGattInfo)); if (bluetoothGattInfo != null && (bluetoothGattInfo.getPropertyType() == PropertyType.PROPERTY_INDICATE || bluetoothGattInfo.getPropertyType() == PropertyType.PROPERTY_NOTIFY)) { DeviceMirror deviceMirror = mDeviceMirrorPool.getDeviceMirror(bluetoothLeDevice); if (deviceMirror != null) { deviceMirror.setNotifyListener(bluetoothGattInfo.getGattInfoKey(), receiveCallback); } } }
Example 3
Source File: DeviceMirror.java From BLE with Apache License 2.0 | 6 votes |
/** * 连接状态改变,主要用来分析设备的连接与断开 * @param gatt GATT * @param status 改变前状态 * @param newState 改变后状态 */ @Override public void onConnectionStateChange(final BluetoothGatt gatt, final int status, final int newState) { ViseLog.i("onConnectionStateChange status: " + status + " ,newState: " + newState + " ,thread: " + Thread.currentThread()); if (newState == BluetoothGatt.STATE_CONNECTED) { gatt.discoverServices(); } else if (newState == BluetoothGatt.STATE_DISCONNECTED) { close(); if (connectCallback != null) { if (handler != null) { handler.removeCallbacksAndMessages(null); } ViseBle.getInstance().getDeviceMirrorPool().removeDeviceMirror(deviceMirror); if (status == BluetoothGatt.GATT_SUCCESS) { connectState = ConnectState.CONNECT_DISCONNECT; connectCallback.onDisconnect(isActiveDisconnect); } else { connectState = ConnectState.CONNECT_FAILURE; connectCallback.onConnectFailure(new ConnectException(gatt, status)); } } } else if (newState == BluetoothGatt.STATE_CONNECTING) { connectState = ConnectState.CONNECT_PROCESS; } }
Example 4
Source File: DeviceMirror.java From BLE with Apache License 2.0 | 6 votes |
/** * 写入属性描述值,主要用来根据当前属性描述值写入数据到设备 * @param gatt GATT * @param descriptor 属性描述值 * @param status 当前状态 */ @Override public void onDescriptorWrite(BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) { ViseLog.i("onDescriptorWrite status: " + status + ", data:" + HexUtil.encodeHexStr(descriptor.getValue()) + " ,thread: " + Thread.currentThread()); if (status == BluetoothGatt.GATT_SUCCESS) { handleSuccessData(writeInfoMap, descriptor.getValue(), status, false); } else { writeFailure(new GattException(status), true); } if (status == BluetoothGatt.GATT_SUCCESS) { handleSuccessData(enableInfoMap, descriptor.getValue(), status, false); } else { enableFailure(new GattException(status), true); } }
Example 5
Source File: DeviceMirror.java From BLE with Apache License 2.0 | 6 votes |
/** * 特征值改变,主要用来接收设备返回的数据信息 * @param gatt GATT * @param characteristic 特征值 */ @Override public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) { ViseLog.i("onCharacteristicChanged data:" + HexUtil.encodeHexStr(characteristic.getValue()) + " ,thread: " + Thread.currentThread()); for (Map.Entry<String, IBleCallback> receiveEntry : receiveCallbackMap.entrySet()) { String receiveKey = receiveEntry.getKey(); IBleCallback receiveValue = receiveEntry.getValue(); for (Map.Entry<String, BluetoothGattChannel> gattInfoEntry : enableInfoMap.entrySet()) { String bluetoothGattInfoKey = gattInfoEntry.getKey(); BluetoothGattChannel bluetoothGattInfoValue = gattInfoEntry.getValue(); if (receiveKey.equals(bluetoothGattInfoKey)) { receiveValue.onSuccess(characteristic.getValue(), bluetoothGattInfoValue, bluetoothLeDevice); } } } }
Example 6
Source File: DeviceMirror.java From BLE with Apache License 2.0 | 5 votes |
/** * 写入数据失败 * * @param bleException * @param isRemoveCall */ private void writeFailure(BleException bleException, boolean isRemoveCall) { if (writeDataRetryCount < BleConfig.getInstance().getOperateRetryCount()) { writeDataRetryCount++; if (handler != null) { handler.removeMessages(MSG_WRITE_DATA_TIMEOUT); handler.sendEmptyMessageDelayed(MSG_WRITE_DATA_RETRY, BleConfig.getInstance().getOperateRetryInterval()); } ViseLog.i("writeFailure writeDataRetryCount is " + writeDataRetryCount); } else { handleFailureData(writeInfoMap, bleException, isRemoveCall); ViseLog.i("writeFailure " + bleException); } }
Example 7
Source File: MainActivity.java From ViseLog with Apache License 2.0 | 5 votes |
@Override public void onClick(View view) { switch (view.getId()) { case R.id.print_normal_message: Log.v("message", "test message"); ViseLog.v("test message"); break; case R.id.print_normal_object: ViseLog.i(new Boolean(true)); break; case R.id.print_bundle_object: ViseLog.d(new Bundle()); break; case R.id.print_collection_object: printList(); break; case R.id.print_intent_object: ViseLog.w(new Intent()); break; case R.id.print_map_object: printMap(); break; case R.id.print_reference_object: ViseLog.wtf(new SoftReference(0)); break; case R.id.print_throwable_object: ViseLog.e(new NullPointerException("this object is null!")); break; case R.id.print_json_message: printJson(); break; case R.id.print_xml_message: printXml(); break; default: break; } }
Example 8
Source File: BluetoothDeviceManager.java From BLE with Apache License 2.0 | 5 votes |
@Override public void onFailure(BleException exception) { if (exception == null) { return; } ViseLog.i("callback fail:" + exception.getDescription()); BusManager.getBus().post(callbackDataEvent.setSuccess(false)); }
Example 9
Source File: BluetoothDeviceManager.java From BLE with Apache License 2.0 | 5 votes |
@Override public void onFailure(BleException exception) { if (exception == null) { return; } ViseLog.i("notify fail:" + exception.getDescription()); }
Example 10
Source File: DeviceMirror.java From BLE with Apache License 2.0 | 5 votes |
/** * 读取属性描述值,主要用来获取设备当前属性描述的值 * @param gatt GATT * @param descriptor 属性描述 * @param status 当前状态 */ @Override public void onDescriptorRead(BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) { ViseLog.i("onDescriptorRead status: " + status + ", data:" + HexUtil.encodeHexStr(descriptor.getValue()) + " ,thread: " + Thread.currentThread()); if (status == BluetoothGatt.GATT_SUCCESS) { handleSuccessData(readInfoMap, descriptor.getValue(), status, true); } else { readFailure(new GattException(status), true); } }
Example 11
Source File: DeviceMirror.java From BLE with Apache License 2.0 | 5 votes |
/** * 写入特征值,主要用来发送数据到设备 * @param gatt GATT * @param characteristic 特征值 * @param status 当前状态 */ @Override public void onCharacteristicWrite(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) { ViseLog.i("onCharacteristicWrite status: " + status + ", data:" + HexUtil.encodeHexStr(characteristic.getValue()) + " ,thread: " + Thread.currentThread()); if (status == BluetoothGatt.GATT_SUCCESS) { handleSuccessData(writeInfoMap, characteristic.getValue(), status, false); } else { writeFailure(new GattException(status), true); } }
Example 12
Source File: DeviceMirror.java From BLE with Apache License 2.0 | 5 votes |
/** * 读取特征值,主要用来读取该特征值包含的可读信息 * @param gatt GATT * @param characteristic 特征值 * @param status 当前状态 */ @Override public void onCharacteristicRead(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) { ViseLog.i("onCharacteristicRead status: " + status + ", data:" + HexUtil.encodeHexStr(characteristic.getValue()) + " ,thread: " + Thread.currentThread()); if (status == BluetoothGatt.GATT_SUCCESS) { handleSuccessData(readInfoMap, characteristic.getValue(), status, true); } else { readFailure(new GattException(status), true); } }
Example 13
Source File: FaceDetectorActivity.java From ViseFace with Apache License 2.0 | 5 votes |
/** * 保存拍照的图片 * * @param data */ private void saveImage(byte[] data) { File pictureFile = getOutputFile(mContext, "face", "photo.jpg");//拍照图片 File avatarFile = getOutputFile(mContext, "face", "avatar.jpg");//截取人脸图片 if (pictureFile == null || avatarFile == null) { return; } if (pictureFile.exists()) { pictureFile.delete(); } if (avatarFile.exists()) { avatarFile.delete(); } Rect rect = new Rect(); if (mDetectorData != null && mDetectorData.getFaceRectList() != null && mDetectorData.getFaceRectList().length > 0 && mDetectorData.getFaceRectList()[0].right > 0) { rect = mDetectorData.getFaceRectList()[0]; } ViseLog.i("save picture start!"); Bitmap bitmap = getImage(data, rect, 1500, 2000, pictureFile, avatarFile); ViseLog.i("save picture complete!"); if (bitmap != null) { bitmap.recycle(); bitmap = null; } }
Example 14
Source File: FaceDetectorActivity.java From ViseFace with Apache License 2.0 | 5 votes |
@Override public void checkPixels(long pixels, boolean isSupport) { ViseLog.i("checkPixels" + pixels); if (!isSupport) { Toast.makeText(mContext, "手机相机像素达不到要求!", Toast.LENGTH_SHORT).show(); finish(); } }
Example 15
Source File: FaceDetectorActivity.java From ViseFace with Apache License 2.0 | 5 votes |
@Override public void checkPermission(boolean isAllow) { ViseLog.i("checkPermission" + isAllow); if (!isAllow) { Toast.makeText(mContext, "权限申请被拒绝,请进入设置打开权限再试!", Toast.LENGTH_SHORT).show(); finish(); } }
Example 16
Source File: BluetoothDeviceManager.java From BLE with Apache License 2.0 | 4 votes |
@Override public void onConnectFailure(BleException exception) { ViseLog.i("Connect Failure!"); BusManager.getBus().post(connectEvent.setSuccess(false).setDisconnected(false)); }
Example 17
Source File: BluetoothDeviceManager.java From BLE with Apache License 2.0 | 4 votes |
@Override public void onDisconnect(boolean isActive) { ViseLog.i("Disconnect!"); BusManager.getBus().post(connectEvent.setSuccess(false).setDisconnected(true)); }
Example 18
Source File: DeviceScanActivity.java From BLE with Apache License 2.0 | 4 votes |
@Override public void onScanFinish(BluetoothLeDeviceStore bluetoothLeDeviceStore) { ViseLog.i("scan finish " + bluetoothLeDeviceStore); }
Example 19
Source File: FaceDetectorActivity.java From ViseFace with Apache License 2.0 | 4 votes |
@Override public void onDetectorData(DetectorData detectorData) { mDetectorData = detectorData; ViseLog.i("识别数据:" + detectorData); mHandler.sendEmptyMessage(0); }
Example 20
Source File: DeviceScanActivity.java From BLE with Apache License 2.0 | 4 votes |
@Override public void onScanTimeout() { ViseLog.i("scan timeout"); }