类com.facebook.react.bridge.AssertionException源码实例Demo

下面列出了怎么用com.facebook.react.bridge.AssertionException的API类实例代码及写法,或者点击链接到github查看源代码。

@ReactMethod
public void initWithAccessToken(final String accessToken, Promise promise) {
    if (accessToken.equals("")) {
        promise.reject(new JSApplicationIllegalArgumentException("Invalid access token"));
        return;
    }        
    
    if(!checkPermissionForMicrophone()) {
        promise.reject(new AssertionException("Can't init without microphone permission"));
    }        

    TwilioVoiceModule.this.accessToken = accessToken;
    if (BuildConfig.DEBUG) {
        Log.d(TAG, "initWithAccessToken ACTION_FCM_TOKEN");
    }
    registerForCallInvites();
    WritableMap params = Arguments.createMap();
    params.putBoolean("initialized", true);
    promise.resolve(params);
}
 
源代码2 项目: react-native-keychain   文件: KeychainModule.java
/** Block current NON-main thread and wait for user authentication results. */
@Override
public void waitResult() {
  if (Thread.currentThread() == Looper.getMainLooper().getThread())
    throw new AssertionException("method should not be executed from MAIN thread");

  Log.i(KEYCHAIN_MODULE, "blocking thread. waiting for done UI operation.");

  try {
    synchronized (this) {
      wait();
    }
  } catch (InterruptedException ignored) {
    /* shutdown sequence */
  }

  Log.i(KEYCHAIN_MODULE, "unblocking thread.");
}
 
@NonNull
@Override
protected String getEncryptionAlgorithm() {
  throw new AssertionException("Not designed for a call");
}
 
@NonNull
@Override
protected String getEncryptionTransformation() {
  throw new AssertionException("Not designed for a call");
}
 
 同包方法