本文整理汇总了Java中io.reactivex.CompletableObserver类的典型用法代码示例。如果您正苦于以下问题:Java CompletableObserver类的具体用法?Java CompletableObserver怎么用?Java CompletableObserver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompletableObserver类属于io.reactivex包,在下文中一共展示了CompletableObserver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompletableObserver
import io.reactivex.CompletableObserver; //导入依赖的package包/类
private CompletableObserver getCompletableObserver() {
return new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
Log.d(TAG, " onSubscribe : " + d.isDisposed());
}
@Override
public void onComplete() {
textView.append(" onComplete");
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " onComplete");
}
@Override
public void onError(Throwable e) {
textView.append(" onError : " + e.getMessage());
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " onError : " + e.getMessage());
}
};
}
示例2: subscribeActual
import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override
protected void subscribeActual(final CompletableObserver completableObserver) {
verifyMainThread();
final View view = viewWeakRef.get();
if (view == null) {
completableObserver.onComplete();
return;
}
final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);
completableObserver.onSubscribe(createAnimationDisposable(animator, onAnimationCancelAction));
if (preTransformActions != null) {
applyActions(preTransformActions, animator);
animator.setDuration(NONE).setStartDelay(NONE)
.withEndAction(() -> runAnimation(completableObserver, animator))
.start();
} else {
runAnimation(completableObserver, animator);
}
}
示例3: onDeleteCheckPoint
import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override public void onDeleteCheckPoint(int adapterPosition) {
getCheckPointDataSource().deleteCheckPoint(allCheckPoints.get(adapterPosition))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new CompletableObserver() {
@Override public void onSubscribe(Disposable d) {
}
@Override public void onComplete() {
allCheckPoints.remove(adapterPosition);
getView().removeMarker(adapterPosition);
getView().notifyListAdapter();
}
@Override public void onError(Throwable e) {
getView().showError("Delete Failed");
}
});
}
示例4: subscribeActual
import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override
protected void subscribeActual(CompletableObserver s) {
CompletableObserver observer;
try {
observer = ObjectHelper.requireNonNull(s, "Null Observer");
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
// can't call onError because no way to know if a Disposable has been set or not
// can't call onSubscribe because the call might have set a Disposable already
RxJavaPlugins.onError(e);
NullPointerException npe = new NullPointerException("Actually not, but can't throw other exceptions due to RS");
npe.initCause(e);
throw npe;
}
source.subscribe(new AttachCompletableObserver(observer, this.compositeDisposable));
}
示例5: subscribeActual
import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override
protected void subscribeActual(CompletableObserver observer) {
boolean b;
try {
b = condition.getAsBoolean();
} catch (Throwable ex) {
EmptyDisposable.error(ex, observer);
return;
}
if (b) {
then.subscribe(observer);
} else {
orElse.subscribe(observer);
}
}
示例6: getObserver
import io.reactivex.CompletableObserver; //导入依赖的package包/类
private CompletableObserver getObserver() {
return new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
Log.d(TAG, " onSubscribe : " + d.isDisposed());
}
@Override
public void onError(Throwable e) {
textView.append(" onError : " + e.getMessage());
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " onError : " + e.getMessage());
}
@Override
public void onComplete() {
textView.append(" onComplete");
textView.append(AppConstant.LINE_SEPARATOR);
Log.d(TAG, " onComplete");
}
};
}
示例7: apply
import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Override
public CompletableObserver apply(CompletableObserver observer) throws Exception {
return new DisposableCompletableObserver() {
@Override
public void onComplete() {
if (!isDisposed()) {
observer.onError(throwable);
}
}
@Override
public void onError(Throwable ex) {
if (!isDisposed()) {
observer.onError(ex);
}
}
};
}
示例8: failOrCountDownCompletableObserver
import io.reactivex.CompletableObserver; //导入依赖的package包/类
protected CompletableObserver failOrCountDownCompletableObserver(CountDownLatch latch) {
return new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
latch.countDown();
}
@Override
public void onError(Throwable e) {
fail(e);
}
};
}
示例9: toCompletableObserver
import io.reactivex.CompletableObserver; //导入依赖的package包/类
/**
* Performs the opposite translation from
* {@link MaybeConsumers#fromCompletableObserver(CompletableObserver)}
*/
public static CompletableObserver toCompletableObserver(final MaybeConsumer<Success> c) {
return new CompletableObserver() {
@Override
public void onSubscribe(@NonNull Disposable d) {
// do nothing
}
@Override
public void onComplete() {
c.success(Success.SUCCESS);
}
@Override
public void onError(@NonNull Throwable e) {
c.fail(throwableToException(e));
}
};
}
示例10: observe
import io.reactivex.CompletableObserver; //导入依赖的package包/类
public static CompletableObserver observe(String tag, String operation) {
return new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
}
@Override
public void onError(Throwable e) {
complain(e, tag, operation);
}
};
}
示例11: decks_renamed
import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Test
public void decks_renamed() {
List<Deck> renamedData = mUser.save().andThen((final CompletableObserver cs) -> {
Deck deck = new Deck(mUser);
deck.setName("ToRename");
deck.setAccepted(true);
deck.create().subscribe(cs);
}).andThen((ObservableSource<List<Deck>>) observer ->
mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
.subscribe(observer)
).firstOrError().flatMapCompletable(data -> {
assertTrue(data.size() == 1 && data.get(0).getName().equals("ToRename"));
Deck fetchedDeck = data.get(0);
fetchedDeck.setName("Renamed");
return fetchedDeck.save();
}).andThen((ObservableSource<List<Deck>>) observer ->
mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
.subscribe(observer)
).firstOrError().blockingGet();
assertTrue(renamedData.size() == 1 && renamedData.get(0).getName()
.equals("Renamed"));
}
示例12: decks_changedDeckType
import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Test
public void decks_changedDeckType() {
List<Deck> deckTypeData = mUser.save().andThen((final CompletableObserver cs) -> {
Deck deck = new Deck(mUser);
deck.setName("DeckType");
deck.setAccepted(true);
deck.create().subscribe(cs);
}).andThen((ObservableSource<List<Deck>>) observer ->
mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
.subscribe(observer)
).firstOrError().flatMapCompletable(data -> {
assertTrue(data.size() == 1 && data.get(0).getName().equals("DeckType"));
Deck fetchedDeck = data.get(0);
fetchedDeck.setDeckType(DeckType.SWISS.name());
return fetchedDeck.save();
}).andThen((ObservableSource<List<Deck>>) observer ->
mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
.subscribe(observer)
).firstOrError().blockingGet();
assertTrue(deckTypeData.size() == 1 && deckTypeData.get(0).getDeckType()
.equals(DeckType.SWISS.name()));
}
示例13: decks_createdAndDeleted
import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Test
public void decks_createdAndDeleted() throws Exception {
List<Deck> deletedDeck = mUser.save().andThen((final CompletableObserver cs) -> {
Deck deck = new Deck(mUser);
deck.setName("Created");
deck.setAccepted(true);
deck.create().subscribe(cs);
}).andThen((ObservableSource<List<Deck>>) observer ->
mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
.subscribe(observer)
).firstOrError().flatMapCompletable(data -> {
assertTrue(data.size() == 1 && data.get(0).getName().equals("Created"));
return data.get(0).delete();
}).andThen((ObservableSource<List<Deck>>) observer ->
mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
.subscribe(observer)
).firstOrError().blockingGet();
assertTrue(deletedDeck.size() == 0);
}
示例14: cards_createdAndFetched
import io.reactivex.CompletableObserver; //导入依赖的package包/类
@Test
public void cards_createdAndFetched() throws Exception {
final Deck deck = new Deck(mUser);
List<Card> cards = mUser.save().andThen((final CompletableObserver cs) -> {
deck.setName("CreateCards");
deck.setAccepted(true);
deck.create().subscribe(cs);
}).andThen((ObservableSource<List<Deck>>) observer ->
mUser.fetchChildren(mUser.getChildReference(Deck.class), Deck.class)
.subscribe(observer)
).firstOrError().flatMapCompletable(data -> {
assertTrue(data.size() == 1 && data.get(0).getName().equals("CreateCards"));
Card newCard = new Card(data.get(0));
newCard.setFront("frontSide");
newCard.setBack("backSide");
return newCard.create();
}).andThen((ObservableSource<List<Card>>) observer ->
deck.fetchChildren(deck.getChildReference(Card.class), Card.class)
.subscribe(observer)
).firstOrError().blockingGet();
assertTrue(cards.size() == 1 && cards.get(0).getFront().equals("frontSide") &&
cards.get(0).getBack().equals("backSide"));
}
示例15: failOrCountDownCompletableObserver
import io.reactivex.CompletableObserver; //导入依赖的package包/类
protected CompletableObserver failOrCountDownCompletableObserver(CountDownLatch latch) {
return new CompletableObserver() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onComplete() {
latch.countDown();
}
@Override
public void onError(Throwable e) {
fail(e);
}
};
}