當前位置: 首頁>>代碼示例>>Java>>正文


Java Callback.invoke方法代碼示例

本文整理匯總了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);
			}
		}
	}
 
開發者ID:lenglengiOS,項目名稱:react-native-blue-manager,代碼行數:21,代碼來源:Peripheral.java

示例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();
    }
}
 
開發者ID:zupzup,項目名稱:react-native-ethereum,代碼行數:22,代碼來源:TestNative.java

示例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);
    }
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:29,代碼來源:WebRTCModule.java

示例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);
}
 
開發者ID:quan-to,項目名稱:react-native-pgp,代碼行數:9,代碼來源:Module.java

示例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());
    }
}
 
開發者ID:MacKentoch,項目名稱:react-native-ibeacons,代碼行數:12,代碼來源:BeaconsAndroidModule.java

示例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());
    }
}
 
開發者ID:emekalites,項目名稱:react-native-compress-image,代碼行數:9,代碼來源:ImageCompressModule.java

示例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());
    }
}
 
開發者ID:StasDoskalenko,項目名稱:react-native-google-fit,代碼行數:13,代碼來源:GoogleFitModule.java

示例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;
        }
    }
}
 
開發者ID:ludo,項目名稱:react-native-torch,代碼行數:36,代碼來源:RCTTorchModule.java

示例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());
    }
}
 
開發者ID:StasDoskalenko,項目名稱:react-native-google-fit,代碼行數:13,代碼來源:GoogleFitModule.java

示例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");
    }
}
 
開發者ID:growingio,項目名稱:react-native-growingio,代碼行數:10,代碼來源:GrowingIOModule.java

示例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());
    }
}
 
開發者ID:StasDoskalenko,項目名稱:react-native-google-fit,代碼行數:9,代碼來源:GoogleFitModule.java

示例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;
    }
}
 
開發者ID:briankabiro,項目名稱:react-native-get-sms-android,代碼行數:16,代碼來源:SmsModule.java

示例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);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:8,代碼來源:NetworkRecordingModuleMock.java


注:本文中的com.facebook.react.bridge.Callback.invoke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。