本文整理汇总了Java中com.facebook.react.bridge.Callback类的典型用法代码示例。如果您正苦于以下问题:Java Callback类的具体用法?Java Callback怎么用?Java Callback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Callback类属于com.facebook.react.bridge包,在下文中一共展示了Callback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clear
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
/**
* Clears the database.
*/
@ReactMethod
public void clear(final Callback callback) {
new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
@Override
protected void doInBackgroundGuarded(Void... params) {
if (!mReactDatabaseSupplier.ensureDatabase()) {
callback.invoke(AsyncStorageErrorUtil.getDBError(null));
return;
}
try {
mReactDatabaseSupplier.clear();
callback.invoke();
} catch (Exception e) {
FLog.w(ReactConstants.TAG, e.getMessage(), e);
callback.invoke(AsyncStorageErrorUtil.getError(null, e.getMessage()));
}
}
}.execute();
}
示例2: createCommodity
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
@ReactMethod
public void createCommodity (final ReadableMap options, final Callback callback) { // 都是必传的(productDetail 可选)
cleanResponse();
if (!hasAndNotEmpty(options, "productTitle")) {
invokeError(callback, "title is empty");
return;
}
if (!hasAndNotEmpty(options, "productImageUrl")) {
invokeError(callback, "imageUrl is empty");
return;
}
if (!hasAndNotEmpty(options, "productURL")) {
invokeError(callback, "productUrl is empty");
return;
}
UdeskCommodityItem item = new UdeskCommodityItem();
item.setTitle(options.getString("productTitle"));// 商品主标题
if (hasAndNotEmpty(options, "productDetail")) {
item.setSubTitle(options.getString("productDetail"));//商品副标题
}
item.setThumbHttpUrl(options.getString("productImageUrl"));// 左侧图片
item.setCommodityUrl(options.getString("productURL"));// 商品网络链接
UdeskSDKManager.getInstance().setCommodity(item);
UdeskSDKManager.getInstance().toLanuchChatAcitvity(mReactContext.getApplicationContext());
}
示例3: MeasureVirtualView
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
private MeasureVirtualView(
int reactTag,
float scaledX,
float scaledY,
float scaledWidth,
float scaledHeight,
boolean relativeToWindow,
Callback callback) {
mReactTag = reactTag;
mScaledX = scaledX;
mScaledY = scaledY;
mScaledWidth = scaledWidth;
mScaledHeight = scaledHeight;
mCallback = callback;
mRelativeToWindow = relativeToWindow;
}
示例4: measureLayout
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
/**
* Measures the view specified by tag relative to the given ancestorTag. This means that the
* returned x, y are relative to the origin x, y of the ancestor view. Results are stored in the
* given outputBuffer. We allow ancestor view and measured view to be the same, in which case
* the position always will be (0, 0) and method will only measure the view dimensions.
*/
public void measureLayout(
int tag,
int ancestorTag,
Callback errorCallback,
Callback successCallback) {
try {
measureLayout(tag, ancestorTag, mMeasureBuffer);
float relativeX = PixelUtil.toDIPFromPixel(mMeasureBuffer[0]);
float relativeY = PixelUtil.toDIPFromPixel(mMeasureBuffer[1]);
float width = PixelUtil.toDIPFromPixel(mMeasureBuffer[2]);
float height = PixelUtil.toDIPFromPixel(mMeasureBuffer[3]);
successCallback.invoke(relativeX, relativeY, width, height);
} catch (IllegalViewOperationException e) {
errorCallback.invoke(e.getMessage());
}
}
示例5: attachOnCompleteListener
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
@ReactMethod
public void attachOnCompleteListener(String downloadId, Callback onComplete) {
try {
long dloadId = Long.parseLong(downloadId);
appDownloads.put(dloadId, onComplete);
WritableMap status = downloader.checkDownloadStatus(Long.parseLong(downloadId));
ArrayList<String> alreadyDoneStatuses = new ArrayList<>(Arrays.asList("STATUS_SUCCESSFUL", "STATUS_FAILED"));
String currentStatus = status.getString("status");
if (alreadyDoneStatuses.contains(currentStatus)) {
appDownloads.remove(dloadId);
onComplete.invoke(null, status);
}
} catch (Exception e) {
onComplete.invoke(e.getMessage(), null);
}
}
开发者ID:master-atul,项目名称:react-native-simple-download-manager,代码行数:17,代码来源:ReactNativeDownloadManagerModule.java
示例6: enqueueMeasureVirtualView
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
public void enqueueMeasureVirtualView(
int reactTag,
float scaledX,
float scaledY,
float scaledWidth,
float scaledHeight,
boolean relativeToWindow,
Callback callback) {
enqueueUIOperation(new MeasureVirtualView(
reactTag,
scaledX,
scaledY,
scaledWidth,
scaledHeight,
relativeToWindow,
callback));
}
示例7: startAnimatingNode
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
@ReactMethod
public void startAnimatingNode(
final int animationId,
final int animatedNodeTag,
final ReadableMap animationConfig,
final Callback endCallback) {
mOperations.add(new UIThreadOperation() {
@Override
public void execute(NativeAnimatedNodesManager animatedNodesManager) {
animatedNodesManager.startAnimatingNode(
animationId,
animatedNodeTag,
animationConfig,
endCallback);
}
});
}
示例8: clearCookies
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
public void clearCookies(final Callback callback) {
if (USES_LEGACY_STORE) {
new GuardedResultAsyncTask<Boolean>(mContext) {
@Override
protected Boolean doInBackgroundGuarded() {
getCookieManager().removeAllCookie();
mCookieSaver.onCookiesModified();
return true;
}
@Override
protected void onPostExecuteGuarded(Boolean result) {
callback.invoke(result);
}
}.execute();
} else {
clearCookiesAsync(callback);
}
}
示例9: getWifiSSID
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
@ReactMethod
public void getWifiSSID(Callback callback){
String SSID;
Context context = this.getReactApplicationContext();
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if(networkInfo != null && networkInfo.isConnected()){
WifiManager wifiManager = (WifiManager) context.getSystemService(context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
SSID = wifiInfo.getSSID();
if(SSID.startsWith("\"") && SSID.endsWith("\""))
SSID = SSID.substring(1, SSID.length()-1);
callback.invoke(null, SSID);
}
else{
callback.invoke("Error: unable to retrieve SSID.", null);
}
}
示例10: CropTask
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
private CropTask(
ReactContext context,
String uri,
int x,
int y,
int width,
int height,
Callback success,
Callback error) {
super(context);
if (x < 0 || y < 0 || width <= 0 || height <= 0) {
throw new JSApplicationIllegalArgumentException(String.format(
"Invalid crop rectangle: [%d, %d, %d, %d]", x, y, width, height));
}
mContext = context;
mUri = uri;
mX = x;
mY = y;
mWidth = width;
mHeight = height;
mSuccess = success;
mError = error;
}
示例11: showPopupMenu
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
/**
* Show a {@link PopupMenu}.
*
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
* needs to be the tag of a native view (shadow views can not be anchors)
* @param items the menu items as an array of strings
* @param success will be called with the position of the selected item as the first argument, or
* no arguments if the menu is dismissed
*/
public void showPopupMenu(int reactTag, ReadableArray items, Callback success) {
UiThreadUtil.assertOnUiThread();
View anchor = mTagsToViews.get(reactTag);
if (anchor == null) {
throw new JSApplicationIllegalArgumentException("Could not find view with tag " + reactTag);
}
PopupMenu popupMenu = new PopupMenu(getReactContextForView(reactTag), anchor);
Menu menu = popupMenu.getMenu();
for (int i = 0; i < items.size(); i++) {
menu.add(Menu.NONE, Menu.NONE, i, items.getString(i));
}
PopupMenuCallbackHandler handler = new PopupMenuCallbackHandler(success);
popupMenu.setOnMenuItemClickListener(handler);
popupMenu.setOnDismissListener(handler);
popupMenu.show();
}
示例12: 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);
}
}
示例13: FindTargetForTouchOperation
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
private FindTargetForTouchOperation(
final int reactTag,
final float targetX,
final float targetY,
final Callback callback) {
super();
mReactTag = reactTag;
mTargetX = targetX;
mTargetY = targetY;
mCallback = callback;
}
示例14: 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
示例15: testMultiRemove
import com.facebook.react.bridge.Callback; //导入依赖的package包/类
@Test
public void testMultiRemove() {
final String key1 = "foo1";
final String key2 = "foo2";
final String value1 = "bar1";
final String value2 = "bar2";
JavaOnlyArray keyValues = new JavaOnlyArray();
keyValues.pushArray(getArray(key1, value1));
keyValues.pushArray(getArray(key2, value2));
mStorage.multiSet(keyValues, mock(Callback.class));
JavaOnlyArray keys = new JavaOnlyArray();
keys.pushString(key1);
keys.pushString(key2);
Callback getCallback = mock(Callback.class);
mStorage.multiRemove(keys, getCallback);
Mockito.verify(getCallback, Mockito.times(1)).invoke();
Callback getAllCallback = mock(Callback.class);
mStorage.getAllKeys(getAllCallback);
Mockito.verify(getAllCallback, Mockito.times(1)).invoke(null, mEmptyArray);
mStorage.multiSet(keyValues, mock(Callback.class));
keys.pushString("fakeKey");
Callback getCallback2 = mock(Callback.class);
mStorage.multiRemove(keys, getCallback2);
Mockito.verify(getCallback2, Mockito.times(1)).invoke();
Callback getAllCallback2 = mock(Callback.class);
mStorage.getAllKeys(getAllCallback2);
Mockito.verify(getAllCallback2, Mockito.times(1)).invoke(null, mEmptyArray);
}