本文整理汇总了Java中com.facebook.react.bridge.Callback.invoke方法的典型用法代码示例。如果您正苦于以下问题:Java Callback.invoke方法的具体用法?Java Callback.invoke怎么用?Java Callback.invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.bridge.Callback
的用法示例。
在下文中一共展示了Callback.invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
public void read(UUID serviceUUID, UUID characteristicUUID, Callback callback) {
if (gatt == null) {
callback.invoke("BluetoothGatt is null", null);
return;
}
BluetoothGattService service = gatt.getService(serviceUUID);
BluetoothGattCharacteristic characteristic = findReadableCharacteristic(service, characteristicUUID);
if (characteristic == null) {
callback.invoke("Characteristic " + characteristicUUID + " not found.", null);
} else {
readCallback = callback;
if (!gatt.readCharacteristic(characteristic)) {
readCallback = null;
callback.invoke("Read failed", null);
}
}
}
示例2: test
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void test(String message, Callback cb) {
try {
android.util.Log.d("before", "yay");
NodeHolder nh = NodeHolder.getInstance();
Node node = nh.getNode();
Context ctx = new Context();
if (node != null) {
NodeInfo info = node.getNodeInfo();
EthereumClient ethereumClient = node.getEthereumClient();
Account newAcc = nh.getAcc();
BigInt balanceAt = ethereumClient.getBalanceAt(ctx, new Address("0x22B84d5FFeA8b801C0422AFe752377A64Aa738c2"), -1);
cb.invoke(balanceAt.toString() + " ether found address:" + newAcc.getAddress().getHex());
return;
}
cb.invoke("node was null");
} catch (Exception e) {
android.util.Log.d("", e.getMessage());
e.printStackTrace();
}
}
示例3: processPicture
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
private synchronized void processPicture(byte[] jpeg, int captureTarget, double maxJpegQuality,
int maxSize, int orientation, List<String> paths,
Callback successCallback, Callback errorCallback,
String streamId, int totalPictures) {
Log.d(TAG, "Processing picture");
try {
String path = savePicture(jpeg, captureTarget, maxJpegQuality, maxSize, orientation);
Log.d(TAG, "Saved picture to " + path);
paths.add(path);
if (paths.size() == totalPictures) {
WritableArray pathsArray = Arguments.createArray();
for (String p : paths) {
pathsArray.pushString(p);
}
successCallback.invoke(pathsArray);
imagePorcessingHandler.removeCallbacksAndMessages(null);
}
} catch (IOException e) {
String message = "Could not save picture for stream id " + streamId;
Log.d(TAG, message, e);
errorCallback.invoke(message);
imagePorcessingHandler.removeCallbacksAndMessages(null);
}
}
示例4: randomBytes
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void randomBytes(int size, Callback success) {
SecureRandom sr = new SecureRandom();
byte[] output = new byte[size];
sr.nextBytes(output);
String string = Base64.encodeToString(output, Base64.DEFAULT);
success.invoke(null, string);
}
示例5: retrieveUserSettings
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void retrieveUserSettings(String key, Callback successCallbackUserSettings) {
if (key.equalsIgnoreCase(AppConstants.LOCK_FINGERPRINT)) {
successCallbackUserSettings.invoke(PreferenceHelper.getPrefernceHelperInstace().getBoolean(AppContext,
key, true));
} else {
successCallbackUserSettings.invoke(PreferenceHelper.getPrefernceHelperInstace().getBoolean(AppContext,
key, false));
}
}
开发者ID:hiteshsahu,项目名称:FingerPrint-Authentication-With-React-Native-Android,代码行数:13,代码来源:BiometricModule.java
示例6: stopMonitoring
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void stopMonitoring(String regionId, String beaconUuid, int minor, int major, Callback resolve, Callback reject) {
Region region = createRegion(regionId, beaconUuid, minor, major);
try {
mBeaconManager.stopMonitoringBeaconsInRegion(region);
resolve.invoke();
} catch (Exception e) {
Log.e(LOG_TAG, "stopMonitoring, error: ", e);
reject.invoke(e.getMessage());
}
}
示例7: createCustomCompressedImage
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void createCustomCompressedImage(String imagePath, String directoryPath, int maxWidth, int maxHeight, int quality, final Callback successCb, final Callback failureCb) {
try {
createCustomCompressedImageWithExceptions(imagePath, directoryPath, maxWidth, maxHeight, quality, successCb, failureCb);
} catch (IOException e) {
failureCb.invoke(e.getMessage());
}
}
示例8: getDailyStepCountSamples
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void getDailyStepCountSamples(double startDate,
double endDate,
Callback errorCallback,
Callback successCallback) {
try {
successCallback.invoke(mGoogleFitManager.getStepHistory().aggregateDataByDate((long)startDate, (long)endDate));
} catch (IllegalViewOperationException e) {
errorCallback.invoke(e.getMessage());
}
}
示例9: switchState
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void switchState(Boolean newState, Callback successCallback, Callback failureCallback) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
CameraManager cameraManager =
(CameraManager) this.myReactContext.getSystemService(Context.CAMERA_SERVICE);
try {
String cameraId = cameraManager.getCameraIdList()[0];
cameraManager.setTorchMode(cameraId, newState);
successCallback.invoke(true);
} catch (Exception e) {
String errorMessage = e.getMessage();
failureCallback.invoke("Error: " + errorMessage);
}
} else {
Camera.Parameters params;
if (!isTorchOn) {
camera = Camera.open();
params = camera.getParameters();
params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
camera.setParameters(params);
camera.startPreview();
isTorchOn = true;
} else {
params = camera.getParameters();
params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
camera.setParameters(params);
camera.stopPreview();
camera.release();
isTorchOn = false;
}
}
}
示例10: getDailyCalorieSamples
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void getDailyCalorieSamples(double startDate,
double endDate,
Callback errorCallback,
Callback successCallback) {
try {
successCallback.invoke(mGoogleFitManager.getCalorieHistory().aggregateDataByDate((long)startDate, (long)endDate));
} catch (IllegalViewOperationException e) {
errorCallback.invoke(e.getMessage());
}
}
示例11: trackPage
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
public void trackPage(final String pageName, final String lastPage, final long ptm, Callback callback) {
if (trackPage(pageName, lastPage, ptm)) {
callback.invoke("the third parameter must be null ,empty String or String of JSONObject");
LogUtil.d(TAG, "trackPage fail");
} else {
callback.invoke(CALLBACK_SUCCESS);
LogUtil.d(TAG, "trackPage success");
}
}
示例12: deleteWeight
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void deleteWeight(ReadableMap weightSample, Callback errorCallback, Callback successCallback) {
try {
successCallback.invoke(mGoogleFitManager.getWeightsHistory().deleteWeight(weightSample));
} catch (IllegalViewOperationException e) {
errorCallback.invoke(e.getMessage());
}
}
示例13: queueDownload
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void queueDownload(String url, ReadableMap headers, ReadableMap config, Callback onStart) {
try {
DownloadManager.Request request = downloader.createRequest(url, headers, config);
long downloadId = downloader.queueDownload(request);
onStart.invoke(null, String.valueOf(downloadId));
} catch (Exception e) {
onStart.invoke(e.getMessage(), null);
}
}
开发者ID:master-atul,项目名称:react-native-simple-download-manager,代码行数:11,代码来源:ReactNativeDownloadManagerModule.java
示例14: delete
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
@ReactMethod
public void delete(Integer id, final Callback errorCallback, final Callback successCallback) {
try {
int res = context.getContentResolver().delete(Uri.parse("content://sms/" + id), null, null);
if (res > 0) {
successCallback.invoke("OK");
} else {
errorCallback.invoke("SMS not found");
}
return;
} catch (Exception e) {
errorCallback.invoke(e.getMessage());
return;
}
}
示例15: fireReactCallback
import com.facebook.react.bridge.Callback; //导入方法依赖的package包/类
private void fireReactCallback(
Callback callback,
int status,
@Nullable String headers,
@Nullable String body) {
callback.invoke(status, headers, body);
}