本文整理匯總了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);
}