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


Java ReactMethod類代碼示例

本文整理匯總了Java中com.facebook.react.bridge.ReactMethod的典型用法代碼示例。如果您正苦於以下問題:Java ReactMethod類的具體用法?Java ReactMethod怎麽用?Java ReactMethod使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ReactMethod類屬於com.facebook.react.bridge包,在下文中一共展示了ReactMethod類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAvailableLocales

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
@ReactMethod 
public void getAvailableLocales(Promise promise) {
	if(notReady(promise)) return;
	
	try {
		WritableArray localeList = Arguments.createArray();
		Locale[] localesArray = Locale.getAvailableLocales();
		for(Locale locale: localesArray) {
			int isAvailable = tts.isLanguageAvailable(locale);
			if(isAvailable == TextToSpeech.LANG_COUNTRY_AVAILABLE) {
				WritableMap newLocale = returnMapForLocale(locale);
				localeList.pushMap(newLocale);
			}
		}

		promise.resolve(localeList);
	} catch(Exception e) {
		promise.reject("error", "Unable to retrieve locales for getAvailableLocales()", e);
	}
}
 
開發者ID:echo8795,項目名稱:react-native-android-text-to-speech,代碼行數:21,代碼來源:RNAndroidTextToSpeechModule.java

示例2: mediaStreamTrackStop

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
@ReactMethod
public void mediaStreamTrackStop(final String id) {
    // Is this functionality equivalent to `mediaStreamTrackRelease()` ?
    // if so, we should merge this two and remove track from stream as well.
    MediaStreamTrack track = mMediaStreamTracks.get(id);
    if (track == null) {
        Log.d(TAG, "mediaStreamTrackStop() track is null");
        return;
    }
    track.setEnabled(false);
    if (track.kind().equals("video")) {
        removeVideoCapturer(id);
    }
    mMediaStreamTracks.remove(id);
    // What exactly does `detached` mean in doc?
    // see: https://www.w3.org/TR/mediacapture-streams/#track-detached
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:18,代碼來源:WebRTCModule.java

示例3: mediaStreamTrackRelease

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
@ReactMethod
public void mediaStreamTrackRelease(final String streamId, final String _trackId) {
    MediaStream stream = mMediaStreams.get(streamId);
    if (stream == null) {
        Log.d(TAG, "mediaStreamTrackRelease() stream is null");
        return;
    }
    MediaStreamTrack track = mMediaStreamTracks.get(_trackId);
    if (track == null) {
        Log.d(TAG, "mediaStreamTrackRelease() track is null");
        return;
    }
    track.setEnabled(false); // should we do this?
    mMediaStreamTracks.remove(_trackId);
    if (track.kind().equals("audio")) {
        stream.removeTrack((AudioTrack)track);
    } else if (track.kind().equals("video")) {
        stream.removeTrack((VideoTrack)track);
        removeVideoCapturer(_trackId);
    }
    imagePorcessingHandler.removeCallbacksAndMessages(null);
    imageProcessingThread.quit();
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:24,代碼來源:WebRTCModule.java

示例4: getPairedDevices

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
/**
 * Get list of paired devices
 *
 * @param promise
 */
@ReactMethod
public void getPairedDevices(Promise promise){
	Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
	// it might need to be an react.bridge.WritableArray
	ArrayList list = new ArrayList();
	for(BluetoothDevice device : pairedDevices){
		list.add(device);
	}

	if(list.size() > 0){
		promise.resolve(list);
	}else{
		promise.reject("Nenhum dispositivo pareado.");
	}
}
 
開發者ID:recs182,項目名稱:react-native-datecs-printer,代碼行數:21,代碼來源:RNDatecsPrinterModule.java

示例5: test

import com.facebook.react.bridge.ReactMethod; //導入依賴的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

示例6: syncImmediately

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
@ReactMethod
public void syncImmediately(int syncInterval, int syncFlexTime) {
    boolean allowForeground = Boolean.valueOf(getReactApplicationContext().getString(R.string.rnsb_allow_foreground));

    if (!allowForeground && HeadlessService.isAppOnForeground(getReactApplicationContext())) {
        if (getCurrentActivity() != null) {
            Toast.makeText(
                    getCurrentActivity(),
                    "This sync task has not been configured to run on the foreground!",
                    Toast.LENGTH_SHORT)
                    .show();
        }
        return;
    }

    SyncAdapter.syncImmediately(getReactApplicationContext(), syncInterval, syncFlexTime);
}
 
開發者ID:ferrannp,項目名稱:react-native-sync-adapter,代碼行數:18,代碼來源:SyncAdapterModule.java

示例7: getCurrentPosition

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
/**
 * Get the current position. This can return almost immediately if the location is cached or
 * request an update, which might take a while.
 *
 * @param options map containing optional arguments: timeout (millis), maximumAge (millis) and
 *        highAccuracy (boolean)
 */
@ReactMethod
public void getCurrentPosition(
    ReadableMap options,
    final Callback success,
    Callback error) {
  LocationOptions locationOptions = LocationOptions.fromReactMap(options);

  try {
    LocationManager locationManager =
        (LocationManager) getReactApplicationContext().getSystemService(Context.LOCATION_SERVICE);
    String provider = getValidProvider(locationManager, locationOptions.highAccuracy);
    if (provider == null) {
      error.invoke(PositionError.buildError(
              PositionError.PERMISSION_DENIED,
              "No location provider available."));
      return;
    }
    Location location = locationManager.getLastKnownLocation(provider);
    if (location != null &&
        SystemClock.currentTimeMillis() - location.getTime() < locationOptions.maximumAge) {
      success.invoke(locationToMap(location));
      return;
    }
    new SingleUpdateRequest(locationManager, provider, locationOptions.timeout, success, error)
        .invoke();
  } catch (SecurityException e) {
    throwLocationPermissionMissing(e);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:37,代碼來源:LocationModule.java

示例8: register

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
@ReactMethod
public void register(final String appKey, final String signature, final Promise promise)
{
	if (_initialised)
	{
		promise.reject(APPTENTIVE, "Apptentive is already initialised");
		return;
	}
	if (appKey == null || appKey.isEmpty())
	{
		promise.reject(APPTENTIVE, "Your appKey is empty");

		return;
	}
	if (signature == null || signature.isEmpty())
	{
		promise.reject(APPTENTIVE, "Your signature is empty");
		return;
	}

	Handler handler = new Handler(_application.getMainLooper());
	Runnable runnable = new Runnable()
	{
		@Override
		public void run()
		{
			Apptentive.register(_application, appKey, signature);
			promise.resolve(true);
			_initialised = true;
		}
	};
	handler.post(runnable);
}
 
開發者ID:erikpoort,項目名稱:react-native-apptentive-module,代碼行數:34,代碼來源:RNApptentiveModule.java

示例9: requestNextPageChannelDescriptors

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
@ReactMethod
public void requestNextPageChannelDescriptors(String sid, final Promise promise) {
    final RCTTwilioChatPaginator tmp = RCTTwilioChatPaginator.getInstance();
    Paginator<ChannelDescriptor> _paginator = (Paginator<ChannelDescriptor>)tmp.paginators.get(sid);

    _paginator.requestNextPage(new CallbackListener<Paginator<ChannelDescriptor>>() {
        @Override
        public void onError(ErrorInfo errorInfo) {
            super.onError(errorInfo);
            promise.reject("request-next-page", "Error occurred while attempting to request the next page. Error Message: " + errorInfo.getErrorText());
        }

        @Override
        public void onSuccess(Paginator<ChannelDescriptor> paginator) {
            String uuid = RCTTwilioChatPaginator.setPaginator(paginator);
            promise.resolve(RCTConvert.Paginator(paginator, uuid, "ChannelDescriptor"));
        }
    });
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:20,代碼來源:RCTTwilioChatPaginator.java

示例10: exitPrinterBuffer

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
/**
 * 退出緩衝模式
 *
 * @param commit: 是否打印出緩衝區內容
 */
@ReactMethod
public void exitPrinterBuffer(boolean commit) {
    final IWoyouService ss = woyouService;
    Log.i(TAG, "come: " + commit + " ss:" + ss);
    final boolean com = commit;
    ThreadPoolManager.getInstance().executeTask(new Runnable() {
        @Override
        public void run() {
            try {
                ss.exitPrinterBuffer(com);
            } catch (Exception e) {
                e.printStackTrace();
                Log.i(TAG, "ERROR: " + e.getMessage());
            }
        }
    });
}
 
開發者ID:januslo,項目名稱:react-native-sunmi-inner-printer,代碼行數:23,代碼來源:SunmiInnerPrinterModule.java

示例11: feedPaper

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
/**
    * Feed paper to the printer (roll out blank paper)
    *
    * @param linesQuantity
    * @param promise
    */
@ReactMethod
public void feedPaper(int linesQuantity, Promise promise) {
	if (linesQuantity < 0 || linesQuantity > 255) {
		promise.reject("AMOUNT_LINES_0_255");
		return;
	}
	try {
		mPrinter.feedPaper(linesQuantity);
		mPrinter.flush();

		promise.resolve("PAPER_FED");
	} catch (Exception e) {
		promise.reject("Erro: " + e.getMessage());
	}
}
 
開發者ID:recs182,項目名稱:react-native-datecs-printer,代碼行數:22,代碼來源:RNDatecsPrinterModule.java

示例12: createAndSendTransaction

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
/**
 * Create and send transaction.
 *
 * @param passphrase Passphrase
 * @param nonce      Account nonce (use -1 to use last known nonce)
 * @param toAddress  Address destination
 * @param amount     Amount
 * @param gasLimit   Gas limit
 * @param gasPrice   Gas price
 * @param data
 * @param promise    Promise
 * @return Return String transaction
 */
@ReactMethod
public void createAndSendTransaction(String passphrase, double nonce, String toAddress,
                                     double amount, double gasLimit, double gasPrice,
                                     String data, Promise promise) {
    try {
        Account acc = GethHolder.getAccount();
        Address fromAddress = acc.getAddress();
        BigInt chain = new BigInt(GethHolder.getNodeConfig().getEthereumNetworkID());
        Context ctx = new Context();

        if (nonce == -1) {
          nonce = GethHolder.getNode().getEthereumClient().getPendingNonceAt(ctx, fromAddress);
        }

        Transaction tx = new Transaction(
                (long) nonce,
                new Address(toAddress),
                new BigInt((long) amount),
                new BigInt((long) gasLimit),
                new BigInt((long) gasPrice),
                data.getBytes("UTF8"));

        // Sign a transaction with a single authorization
        Transaction signed = GethHolder.getKeyStore().signTxPassphrase(acc, passphrase, tx, chain);
        // Send it out to the network.
        GethHolder.getNode().getEthereumClient().sendTransaction(ctx, signed);
        promise.resolve(tx.toString());
    } catch (Exception e) {
        promise.reject(NEW_TRANSACTION_ERROR, e);
    }
}
 
開發者ID:YsnKsy,項目名稱:react-native-geth,代碼行數:45,代碼來源:RNGethModule.java

示例13: retrieveCredentials

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
@ReactMethod
public void retrieveCredentials(Callback errorCallbackCred, Callback successCallbackCred) {

    //Read encrypted JSON from file system
    String encryptedJSONFromFile = readFromFile();

    //decrypt data from file system
    String decryptedJSON = decryptText(encryptedJSONFromFile);

    if (null != decryptedJSON) {
        try {
            JSONObject decryptedJSONObject = new JSONObject(decryptedJSON);
            successCallbackCred.invoke(decryptedJSONObject.toString());
        } catch (JSONException e) {
            e.printStackTrace();
            errorCallbackCred.invoke("Failed to retrieve Credentials");
        }
    } else {
        errorCallbackCred.invoke("Failed to retrieve Credentials");
    }
}
 
開發者ID:hiteshsahu,項目名稱:FingerPrint-Authentication-With-React-Native-Android,代碼行數:22,代碼來源:BiometricModule.java

示例14: isSensorAvailable

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
@ReactMethod
public void isSensorAvailable(final Promise promise) {
    
    response = Arguments.createMap();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (ActivityCompat.checkSelfPermission(mReactContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
            sendResponse("failed", "You haven't allow this app to use your fingerprint sensor", promise);
            return;
        }
        
        if (mReactContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) ||
            ((FingerprintManager) mReactContext.getSystemService(Context.FINGERPRINT_SERVICE)).isHardwareDetected()) {
            if (((FingerprintManager) mReactContext.getSystemService(Context.FINGERPRINT_SERVICE)).hasEnrolledFingerprints()) {
                sendResponse("ok", null, promise);
            } else {
                sendResponse("failed", "You have fingerprint sensor, but you should set it enabled in your settings to use with this app", promise);
            }
        } else {
            sendResponse("failed", "You don\'t have appropriate hardware", promise);
        }
    } else {
        sendResponse("failed", "You don\'t have appropriate hardware", promise);
    }
}
 
開發者ID:ElekenAgency,項目名稱:react-native-touch-id-android,代碼行數:25,代碼來源:FingerprintModule.java

示例15: getPhotos

import com.facebook.react.bridge.ReactMethod; //導入依賴的package包/類
/**
 * Get photos from {@link MediaStore.Images}, most recent first.
 *
 * @param params a map containing the following keys:
 *        <ul>
 *          <li>first (mandatory): a number representing the number of photos to fetch</li>
 *          <li>
 *            after (optional): a cursor that matches page_info[end_cursor] returned by a
 *            previous call to {@link #getPhotos}
 *          </li>
 *          <li>groupName (optional): an album name</li>
 *          <li>
 *            mimeType (optional): restrict returned images to a specific mimetype (e.g.
 *            image/jpeg)
 *          </li>
 *        </ul>
 * @param promise the Promise to be resolved when the photos are loaded; for a format of the
 *        parameters passed to this callback, see {@code getPhotosReturnChecker} in CameraRoll.js
 */
@ReactMethod
public void getPhotos(final ReadableMap params, final Promise promise) {
  int first = params.getInt("first");
  String after = params.hasKey("after") ? params.getString("after") : null;
  String groupName = params.hasKey("groupName") ? params.getString("groupName") : null;
  ReadableArray mimeTypes = params.hasKey("mimeTypes")
      ? params.getArray("mimeTypes")
      : null;
  if (params.hasKey("groupTypes")) {
    throw new JSApplicationIllegalArgumentException("groupTypes is not supported on Android");
  }

  new GetPhotosTask(
        getReactApplicationContext(),
        first,
        after,
        groupName,
        mimeTypes,
        promise)
        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:41,代碼來源:CameraRollManager.java


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