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


Java SingleEmitter.onError方法代碼示例

本文整理匯總了Java中io.reactivex.SingleEmitter.onError方法的典型用法代碼示例。如果您正苦於以下問題:Java SingleEmitter.onError方法的具體用法?Java SingleEmitter.onError怎麽用?Java SingleEmitter.onError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.reactivex.SingleEmitter的用法示例。


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

示例1: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public final void subscribe(SingleEmitter<T> emitter) throws Exception {
    final GoogleApiClient apiClient = createApiClient(new ApiClientConnectionCallbacks(emitter));

    try {
        apiClient.connect();
    } catch (Throwable ex) {
        emitter.onError(ex);
    }

    emitter.setCancellable(new Cancellable() {
        @Override
        public void cancel() throws Exception {
            if (apiClient.isConnected()) {
                RxLocationSingleOnSubscribe.this.onUnsubscribed(apiClient);
            }

            apiClient.disconnect();
        }
    });
}
 
開發者ID:TechIsFun,項目名稱:RxJava2-weather-example,代碼行數:22,代碼來源:RxLocationSingleOnSubscribe.java

示例2: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(final SingleEmitter<QuerySnapshot> emitter) throws Exception {
    OnCompleteListener<QuerySnapshot> listener = new OnCompleteListener<QuerySnapshot>() {
        @Override
        public void onComplete(@NonNull Task<QuerySnapshot> task) {
            if (!emitter.isDisposed()) {
                if (task.isSuccessful()) {
                    emitter.onSuccess(task.getResult());

                } else {
                    emitter.onError(task.getException());

                }
            }

        }
    };

    collectionReference.get()
            .addOnCompleteListener(listener);
}
 
開發者ID:btrautmann,項目名稱:RxFirestore,代碼行數:22,代碼來源:GetCollectionOnSubscribe.java

示例3: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public final void subscribe(SingleEmitter<T> emitter) throws Exception {
    final GoogleApiClient apiClient = createApiClient(new ApiClientConnectionCallbacks(emitter));

    try {
        apiClient.connect();
    } catch (Throwable ex) {
        emitter.onError(ex);
    }

    emitter.setCancellable(() -> {
        if (apiClient.isConnected()) {
            onUnsubscribed(apiClient);
        }

        apiClient.disconnect();
    });
}
 
開發者ID:florent37,項目名稱:RxGps,代碼行數:19,代碼來源:RxLocationSingleOnSubscribe.java

示例4: listener

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
/**
 * @param emit
 * @param <R>
 * @return
 */
@NonNull
@CheckReturnValue
public static <R> OnCompleteListener<R> listener(@NonNull final SingleEmitter<R> emit) {
    return new OnCompleteListener<R>() {
        @Override
        public void onComplete(@NonNull final Task<R> task) {
            if (!emit.isDisposed()) {
                if (task.isSuccessful()) {
                    emit.onSuccess(task.getResult());
                } else {
                    Exception e = task.getException();
                    emit.onError(e != null ? e : new RuntimeException());
                }
            }
        }
    };
}
 
開發者ID:yongjhih,項目名稱:rxtasks,代碼行數:23,代碼來源:RxTask.java

示例5: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override public void subscribe(final SingleEmitter<String> emitter) {
  OnCompleteListener<GetTokenResult> listener = new OnCompleteListener<GetTokenResult>() {
    @Override public void onComplete(@NonNull Task<GetTokenResult> task) {
      if (!task.isSuccessful()) {
        if (!emitter.isDisposed()) {
          emitter.onError(task.getException());
        }
        return;
      }

      if (!emitter.isDisposed()) {
        emitter.onSuccess(task.getResult().getToken());
      }
    }
  };

  user.getToken(forceRefresh).addOnCompleteListener(listener);
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:19,代碼來源:UserGetTokenOnSubscribe.java

示例6: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override public void subscribe(final SingleEmitter<FirebaseUser> emitter) {
  final OnCompleteListener<AuthResult> listener = new OnCompleteListener<AuthResult>() {
    @Override public void onComplete(@NonNull Task<AuthResult> task) {
      if (!task.isSuccessful()) {
        if (!emitter.isDisposed()) {
          emitter.onError(task.getException());
        }
        return;
      }

      if (!emitter.isDisposed()) {
        emitter.onSuccess(task.getResult().getUser());
      }
    }
  };
  createAuthTask(instance).addOnCompleteListener(listener);
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:BaseAuthOnSubscribe.java

示例7: listener

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
public static <T> OnCompleteListener<T> listener(@NonNull final SingleEmitter<T> emitter) {
  return new OnCompleteListener<T>() {
    @Override public void onComplete(@NonNull Task<T> task) {
      if (!task.isSuccessful()) {
        if (!emitter.isDisposed()) {
          emitter.onError(task.getException());
        }
        return;
      }

      if (!emitter.isDisposed()) {
        emitter.onSuccess(task.getResult());
      }
    }
  };
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:17,代碼來源:GmsTaskListeners.java

示例8: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override public void subscribe(final SingleEmitter<DataSnapshot> emitter) {
  final ValueEventListener listener = new ValueEventListener() {
    @Override public void onDataChange(DataSnapshot dataSnapshot) {
      if (!emitter.isDisposed()) {
        emitter.onSuccess(dataSnapshot);
      }
    }

    @Override public void onCancelled(DatabaseError databaseError) {
      if (!emitter.isDisposed()) {
        emitter.onError(databaseError.toException());
      }
    }
  };

  ref.addListenerForSingleValueEvent(listener);
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:18,代碼來源:DataOnSubscribe.java

示例9: listener

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
/**
 * @param emit
 * @return
 */
@NonNull
@CheckReturnValue
public static ValueEventListener listener(@NonNull final SingleEmitter<DataSnapshot> emit) {
    return new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if (!emit.isDisposed()) {
                emit.onSuccess(dataSnapshot);
            }
        }

        @Override
        public void onCancelled(DatabaseError e) {
            if (!emit.isDisposed()) {
                emit.onError(e.toException());
            }
        }
    };
}
 
開發者ID:yongjhih,項目名稱:rxfirebase,代碼行數:24,代碼來源:RxValue.java

示例10: createDirectory

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@NonNull private String createDirectory(SingleEmitter<String> e) {
  File appDir =
      new File(Environment.getExternalStorageDirectory() + "/AppPermissionsExtractedApk");
  if (!appDir.exists()) {
    if (!appDir.mkdir()) {
      e.onError(new Exception("Error creating directory"));
    }
  }
  return appDir.getPath();
}
 
開發者ID:Arjun-sna,項目名稱:android-permission-checker-app,代碼行數:11,代碼來源:AppDetailsPresenterImpl.java

示例11: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(SingleEmitter<GoogleSignInAccount> emitter) throws Exception {
  if (!result.isSuccess()) {
    emitter.onError(new GoogleSignInException(result));
    return;
  }

  emitter.onSuccess(result.getSignInAccount());
}
 
開發者ID:ashdavies,項目名稱:eternity,代碼行數:10,代碼來源:GoogleSignInResultSingle.java

示例12: transaction

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
/**
 * @param emitter
 * @param function
 * @return
 */
@NonNull
@CheckReturnValue
public static Transaction.Handler transaction(
        @NonNull final SingleEmitter<DataSnapshot> emitter,
        @NonNull final Function<MutableData, Transaction.Result> function) {
    return new Transaction.Handler() {
        @Override
        public Transaction.Result doTransaction(MutableData mutableData) {
            try {
                return function.apply(mutableData);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public void onComplete(@Nullable DatabaseError databaseError,
                               boolean committed,
                               @NonNull DataSnapshot dataSnapshot) {
            if (!emitter.isDisposed()) {
                if (null == databaseError) {
                    emitter.onSuccess(dataSnapshot);
                } else {
                    emitter.onError(databaseError.toException());
                }
            }
        }
    };
}
 
開發者ID:yongjhih,項目名稱:rxfirebase,代碼行數:35,代碼來源:RxValue.java

示例13: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(@NonNull SingleEmitter<Result> emitter) throws Exception {
    try {
        final Result value = preparedOperation.executeAsBlocking();
        emitter.onSuccess(value);
    } catch (Exception e) {
        emitter.onError(e);
    }
}
 
開發者ID:pushtorefresh,項目名稱:storio,代碼行數:10,代碼來源:SingleOnSubscribeExecuteAsBlocking.java

示例14: subscribe

import io.reactivex.SingleEmitter; //導入方法依賴的package包/類
@Override
public void subscribe(@NonNull SingleEmitter<Optional<Result>> emitter) throws Exception {
    try {
        final Result value = preparedOperation.executeAsBlocking();
        emitter.onSuccess(Optional.of(value));
    } catch (Exception e) {
        emitter.onError(e);
    }
}
 
開發者ID:pushtorefresh,項目名稱:storio,代碼行數:10,代碼來源:SingleOnSubscribeExecuteAsBlockingOptional.java


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